'complex' function with string argument.

Ian Kelly ian.g.kelly at gmail.com
Mon Mar 17 14:28:05 EDT 2014


On Mon, Mar 17, 2014 at 12:15 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Is "-2.0" a literal?
>
> What's the outcome of
>
>    -2.0.__str__()

No.  The compiler will try to optimize it into a single constant if it
can, but it has to be done in accordance with the order of operations.
 In that example, the __str__ method is called before the unary - is
applied, resulting in an error.



More information about the Python-list mailing list