Hi,

I'm still on Python 2.6 and I'm trying to work some unicode handling.

I've spent some hours on this snippet of code, trying to follow PEP 0263,
since the error tells me to see it.  I've tried other docs too and I am
still clueless.

The code works, except for the comment at the end.

I would be very grateful for some help.


#!/usr/bin/env python
'''Unicode handling for 2.6.
'''
class Currency(float):
    def __str__(self):
        value = self.__class__.symbol +  float.__str__(self)
        return value

class Yen(Currency):
    symbol = unichr(165)

class Pound(Currency):
    symbol = unichr(163)

def main():
    y = Yen(100)
    print unicode(y)
    p = Pound(100)
    print unicode(p)

main()

"""
¥100.0
£100.0
"""



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to