A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-June/024905.html below:

[Python-Dev] Numeric conversions

[Python-Dev] Numeric conversions [Python-Dev] Numeric conversionsAahz aahz@pythoncraft.com
Sun, 2 Jun 2002 11:56:33 -0400
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?
-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"In the end, outside of spy agencies, people are far too trusting and
willing to help."  --Ira Winkler




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