'complex' function with string argument.

Marko Rauhamaa marko at pacujo.net
Mon Mar 17 14:15:55 EDT 2014


Chris Angelico <rosuav at gmail.com>:

> On Tue, Mar 18, 2014 at 3:18 AM, Mark H Harris <harrismh777 at gmail.com> wrote:
>> Philosophically, I tend to think about it this way. A complex number
>> is like any other number. I would not form a PI string like this> ' 3
>> .14 1 5 9265 3 . . .' I would rather see it formed like so,
>> '3.1415926535'
>
> Right.

Well, Java 7 allows you to embed underscores freely in numeric literals.
Would be a nice addition to Python as well:

   if unit == 'G':
       count *= 1_000_000_000

vs:

   if unit == 'G':
       count *= 1000000000


>> 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__()


Marko



More information about the Python-list mailing list