Length limit for variable names in your language?

David C. Ullrich ullrich at math.okstate.edu
Sat May 12 13:51:10 EDT 2001


On Fri, 11 May 2001 15:14:40 -0700, No Na Me <No_Na_Me at my-deja.com>
wrote:

>What this limit is for
>C++,Fortran,Lisp,Pascal etcetcetc
>
>Since this is multi-newsggroups message
>please do not forget mention the language :-)

Looks like variable names can be at least
12,000,000 characters long in Python:

N=1000000
name='variablename'*N
print len(name)

assignment='%s = 42' % name
printer='print %s' % name

exec(assignment)
exec(printer)

works as expected (eventually). And all 12,000,000
characters appear to be significant - if you trim the last
character off the variable name, as in

printer='print %s' % name[:-1]

then you get a NameError.

David C. Ullrich
***********************
"Sometimes you can have access violations all the
time and the program still works." (Michael Caracena,
comp.lang.pascal.delphi.misc 5/1/01)



More information about the Python-list mailing list