How can I make a class that can be converted into an int?
mikael at isy.liu.se
Mon Oct 2 17:12:58 CEST 2006
Matthew Wilson wrote:
> 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
From Python Reference Manual, section 3.4.7 Emulating numeric types:
Called to implement the built-in functions complex(), int(),
long(), and float(). Should return a value of the appropriate type.
More information about the Python-list