On Tue, Mar 18, 2014 at 5:15 AM, Marko Rauhamaa <ma...@pacujo.net> wrote: >>> This '3 + 2j' is not a number, its an algebraic sum. >>> >>> This '3+2j' is a complex number. Ok, maybe not, but its closer to what >>> we expect (I'm sorry, but I like i instead of j ) >> >>Hmm. That's a pretty tricky distinction. > > Is "-2.0" a literal? > > What's the outcome of > > -2.0.__str__()
If you mean (-2.0).__str__(), then it returns '-2.0', but that proves nothing. Lots of objects have a str() which isn't a literal. Closer to what you're talking about would be repr(), but even then, it doesn't prove that something's a literal. The easiest way to tell is probably ast.parse(): >>> ast.dump(ast.parse("-2.0")) 'Module(body=[Expr(value=UnaryOp(op=USub(), operand=Num(n=2.0)))])' It's an expression consisting of unary minus and the float literal 2.0. ChrisA -- https://mail.python.org/mailman/listinfo/python-list