A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-November/049926.html below:

[Python-Dev] Int literals and method calls

[Python-Dev] Int literals and method calls [Python-Dev] Int literals and method callsSimon Percivall s.percivall at chello.se
Mon Nov 15 13:31:44 CET 2004
On 2004-11-15, at 10.54, Gerrit wrote:
>
> It works for complex numbers:
>
>>>> 1j.imag
> 1.0
>
> ...in a rather surprising way:
>
>>>> 3+4j.real
> 3.0
>>>> f() + 5j.real
> 42.0
>
> I would have expected it to be 0.0, because I would have expected the
> '.' to have precedence over the '+', but it hasn't. apparantly.
>
> [...]
>
> I would call it inconsistent:
>
>     3+4j.real means (3+4j).real
>     3+4j.__class__ means 4+(4j).__class__

No, it means 3 + (4j.real) which is the same as 3 + 0.0. Both equals 
3.0.

//Simon

More information about the Python-Dev mailing list

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