What is the maximum length for an attribute name in python?

Since attribute names just get hashed and turned in to keys on inst.__dict__ for 99% of classes you'll ever encounter, there's no real limit on length. As long as it is hashable, it'll work as an attribute name. For the other 1% of classes that fiddle with __setattr__\ __getattr__\ __getattribute__ in ways that break the guarantee that anything hashable is a valid attribute name though, the previous does not apply.

Of course, as others have pointed out, you will have code style and quality concerns with longer named attributes. If you are finding yourself needing such long names, it's likely indicative of a design flaw in your program, and you should probably look at giving your data more hierarchical structure and better abstracting and dividing responsibility in your functions and methods.


2.3. Identifiers and keywords from The Python Language Reference:

Identifiers are unlimited in length.


But you'll be violating PEP-8 most likely, which is not really cool:

Limit all lines to a maximum of 79 characters.

Also you'll be violating PEP-20 (the Zen of Python):

Readability counts.


They could be a problem for the programmer. Keep the function names reasonably short, and use docstrings to document them.