キーワードの前後にスペースが含まれないことがあるのはなぜですか?たとえば、式2if-1e1else 1
が有効な理由は何ですか?なぜPythonは常にキーワードの周りにスペースを必要としませんか?
はCPython 2.7および3.3の両方で動作するように思われる:
$ python2
Python 2.7.3 (default, Nov 12 2012, 09:50:25)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 2if-1e1else 1
2
$ python3
Python 3.3.0 (default, Nov 12 2012, 10:01:55)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 2if-1e1else 1
2
ともPyPyで:
したがってidentifier ::= (letter|"_") (letter | digit | "_")*
、2if
:Pythonで
$ pypy
Python 2.7.2 (341e1e3821ff, Jun 07 2012, 15:42:54)
[PyPy 1.9.0 with GCC 4.2.1] on darwin
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``PyPy 1.6 released!''
>>>> 2if-1e1else 1
2
wtf – wim
perlのように見え始めています – jamylak