With the help of, getattryou can access attributes whose names are not valid identifiers, although I'm not sure that a use case is used to use such attributes, and not to use a dictionary.
>>> setattr(t, '3', lambda : 4)
>>> t.3()
File "<stdin>", line 1
t.3()
^
SyntaxError: invalid syntax
>>> getattr(t, '3')()
4
source
share