Function name limit in Python ?
Steven D'Aprano
steve at pearwood.info
Sat Feb 14 22:34:04 EST 2009
Linuxguy123 wrote:
> Excuse my ignorance, but is there a limit to the size of function names
> in Python ?
>
> I named a function getSynclientVersion() and I got an error when I
> called it.
No no, don't tell us what error you got! I love guessing games. I'm guessing
you got either a SyntaxError or a NameError.
> I renamed the same function to getSCVersion() and it called
> fine.
>>> def python_allows_really_long_function_names_with_no_problem():
... print "hello world"
...
>>> python_allows_really_long_function_names_with_no_problem()
hello world
>>>
>>> ptyhon_allows_really_long_function_names_with_no_problem()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'ptyhon_allows_really_long_function_names_with_no_problem'
is not defined
Can you spot the difference? More importantly, can you see how the error
message actually tells you what the error is?
--
Steven
More information about the Python-list
mailing list