'complex' function with string argument.
rosuav at gmail.com
Mon Mar 17 20:32:18 CET 2014
On Tue, Mar 18, 2014 at 6:22 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>> On Tue, Mar 18, 2014 at 5:15 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>> Is "-2.0" a literal?
>>> What's the outcome of
>> If you mean (-2.0).__str__(), then it returns '-2.0', but that proves
> The point is, you don't need to "philosophize" about complex literals
> when even negative numbers don't have literals in Python.
Ah! I get you.
The difference between literals and constants is one that almost never
matters, though. Python may not have a syntax for negative or complex
literals, but it does have notations for various sorts of constants,
which function the same way. (Literals are by definition constants.)
So Python may not have a convenient notation for "number of seconds in
a week" (unless you work with DNS and find the bare integer 604800
convenient), but you can write 7*24*60*60 and it's just as good in a
op=Mult(), right=Num(n=24)), op=Mult(), right=Num(n=60)), op=Mult(),
>>> def f(x):
return x + 7*24*60*60
2 0 LOAD_FAST 0 (x)
3 LOAD_CONST 6 (604800)
There's absolutely no run-time cost to writing it out, and you get to
be flexible with whitespace and such, which you can't do with
More information about the Python-list