Emanuel Barry added the comment:
Any valid variable name can be used as a an attribute; for example, "spam" is
valid while "spam-eggs" is not. This isn't unique to classes, but to all
assignments everywhere. If we allowed `o.exec = blah` then we should also allow
`exec =
luav added the comment:
I'm sorry for the previous question, now it's clear (the space is allowed after
the '.' which complicates the parsing):
```
>>> o.e = 1
>>> o. e
1
>>> o.e
1
```
Anyway, it would be nice to outline the eligible values for attributes in the
luav added the comment:
Why Python 2 documentation does not outline that keywords / statements can't be
used as the object attributes?
https://docs.python.org/2/reference/simple_stmts.html#exec
And why does this restriction exist at all? The keywords always stand-alone and
Emanuel Barry added the comment:
This is because `exec` is a keyword in Python 2, whereas in Python 3 it's a
function.
--
nosy: +ebarry
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
New submission from luav :
The following code works fine on Python 3.5.2 but `exec` attribute fails to be
set to the object on Python 2.7.12:
```python
>>> o = type('O', (object,), {})
>>> o.e = 1
>>> o.eval = 1
>>> o.exec = 1
File "", line 1
o.exec = 1
^