In Py2 the name of an identifier is quite restricted like in most other programming languages, too. This means it is only allowed to contain alphanumeric characters, must not start with a digit, no space, ....I am afraid that's not possible. It is exactly because the label can be changed to anything, e.g. with space, it must be quoted, with the double bracket. It's just a bit unfortunate that the quoting style is not so natural.
However, in Py3 an identifier is allowed to actually contain any character -- even a dot or any kind of unicode. Of course when using such special characters you cannot use the identifier directly but instead you must use setattr/getattr.
Example:
Code: Select all
import __main__
setattr(__main__,"an identifier with a .", "test")
dir()