Attachment 'modulo.py'

Download

   1 # -*- coding: utf-8 -*-
   2 
   3 d = {
   4     'name': u'יוניקוד'
   5 }
   6 
   7 class U:
   8     def __str__(self):
   9         print '%s.__str__ called' % self.__class__.__name__
  10         return 'string'
  11     def __unicode__(self):
  12         print '%s.__unicode__ called' % self.__class__.__name__
  13         return u'יוניקוד'
  14 
  15         
  16 print 'insert unicode from dict into unicode'       
  17 assert u'%(name)s' % d == u'יוניקוד'
  18 
  19 print 'insert unicode from string literal into unicode'
  20 assert u'%s' % u'יוניקוד' == u'יוניקוד'
  21 
  22 print 'insert unicode from variable into unicode'
  23 var = u'יוניקוד'
  24 assert u'%s' % var == u'יוניקוד'
  25 
  26 print 'insert unicode from object into unicode'
  27 var = U()
  28 assert u'%s' % unicode(var) == u'יוניקוד'
  29 
  30 print 'insert unicode from dict into string'       
  31 assert '%(name)s' % d == u'יוניקוד'
  32 
  33 print 'insert unicode from string literal into string'
  34 assert '%s' % u'יוניקוד' == u'יוניקוד'
  35 
  36 print 'insert unicode from variable into string'
  37 var = u'יוניקוד'
  38 assert '%s' % var == u'יוניקוד'
  39 
  40 print 'insert unicode from object into string'
  41 var = U()
  42 assert '%s' % unicode(var) == u'יוניקוד'

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2004-10-06 22:16:20, 0.8 KB) [[attachment:add.py]]
  • [get | view] (2004-10-06 22:16:30, 1.1 KB) [[attachment:modulo.py]]
  • [get | view] (2004-10-06 20:06:10, 1.3 KB) [[attachment:uni.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.