How can I make a class that can be converted into an int?
Matthew Wilson
matt at tplus1.com
Mon Oct 2 10:59:05 EDT 2006
More information about the Python-list mailing list
Mon Oct 2 10:59:05 EDT 2006
- Previous message (by thread): How can I make a class that can be converted into an int?
- Next message (by thread): How can I make a class that can be converted into an int?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
What are the internal methods that I need to define on any class so that
this code can work?
c = C("three")
i = int(c) # i is 3
I can handle the part of mapping "three" to 3, but I don't know what
internal method is called when int(c) happens.
For string conversion, I just define the __str__ method. What's the
equivalent for int? For float, too, while I'm at it?
TIA
Matt
--
A better way of running series of SAS programs:
http://overlook.homelinux.net/wilsonwiki/SasAndMakefiles
- Previous message (by thread): How can I make a class that can be converted into an int?
- Next message (by thread): How can I make a class that can be converted into an int?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list