Parentheses (as after "print")

Thomas Jollans tjol at tjol.eu
Wed Sep 27 03:59:49 EDT 2017


On 26/09/17 17:56, Stefan Ram wrote:
>   What happened? I woke up today in parens mood. So I typed:
>
> import( operator )
>
>   Python told me that I should type:
>
> import operator

This is an interesting case:

>>> import (os, sys)
  File "<stdin>", line 1
    import (os, sys)
           ^
SyntaxError: invalid syntax
>>> from os import (listdir, chdir)
>>> listdir, chdir
(<built-in function listdir>, <built-in function chdir>)
>>>

Of course the reasons the second syntax was eventually added to the
language don't apply in the first case, but this does look a bit
inconsistent...

-- Thomas



More information about the Python-list mailing list