Default scope of variables

Rotwang sg552 at
Thu Jul 4 18:54:20 CEST 2013

Sorry to be OT, but this is sending my pedantry glands haywire:

On 04/07/2013 08:06, Dave Angel wrote:
> On 07/04/2013 01:32 AM, Steven D'Aprano wrote:
>        <SNIP>
>> Well, if I ever have more than 63,000,000 variables[1] in a function,
>> I'll keep that in mind.
>      <SNIP>
>> [1] Based on empirical evidence that Python supports names with length at
>> least up to one million characters long, and assuming that each character
>> can be an ASCII letter, digit or underscore.
> Well, the number wouldn't be 63,000,000.  Rather it'd be 63**1000000
> I probably have it wrong, but I think that looks like:
> 859,122,[etc.]
> variables.  (The number has 180 digits)

That's 63**100. Note that 10**1000000 has 1000001 digits, and is 
somewhat smaller than 63**1000000.

Anyway, none of the calculations that has been given takes into account 
the fact that names can be /less/ than one million characters long. The 
actual number of non-empty strings of length at most 1000000 characters, 
that consist only of ascii letters, digits or underscores, and that 
don't start with a digit, is

sum(53*63**i for i in range(1000000)) == 53*(63**1000000 - 1)//62

It's perhaps worth mentioning that some non-ascii characters are allowed 
in identifiers in Python 3, though I don't know which ones.

More information about the Python-list mailing list