I\'m writing a set of python functions that perform some sort of conformance checking on a source code project. I\'d like to specify quite verbose names for these functions,
They could be a problem for the programmer. Keep the function names reasonably short, and use docstrings to document them.
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.
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.