how can I subclass a string (str)?

Matt Gerrans matt_gerrans at hp.com
Tue Aug 13 19:53:01 CEST 2002


This seems to work:

class mystr(str):
   def HexRepr(self):
      print 'A hex on ye!'

and so does this:

class mystr( type('anystring') ):
   def HexRepr(self):
      print 'A hex on ye!'







More information about the Python-list mailing list