From: "Aahz" <aahz@pythoncraft.com> > On Sun, Jun 02, 2002, David Abrahams wrote: > > > > The following small program is giving me some unexpected results with > > Python 2.2.1: > > > > class Int(object): > > def __int__(self): return 10 > > > > class Float(object): > > def __float__(self): return 10.0 > > > > ----- results ------ > > > > int(Int) 10 > > int(Float) TypeError: object can't be converted to int > > Um. I'm confuzzled. Float doesn't have an __int__ method; why do you > expect it to work? I don't. as I wrote below that: *** OK, int() seems to work as expected Each item beginning with '***' is meant to refer to the group of 4 lines above.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4