Re: why a main() function?
In <7xk63zhpln.fsf @ruckus.brouhah a.com>, Paul Rubin wrote:
Which BTW is the reason why ``locals()['answer'] = 42`` does not work
within functions. The dictionary isn't the dictionary that's used for
locals but a proxy just for read access.
Ciao,
Marc 'BlackJack' Rintsch
In <7xk63zhpln.fsf @ruckus.brouhah a.com>, Paul Rubin wrote:
"Diez B. Roggisch" <deets@nospam.w eb.dewrites:
>>
>Interesting. How is the index computed? I would have assumed that locals()
>is somehow used, which is a dicht.
>
They're static indexes assigned at compile time.
Python stores local variables in an indexed array, but globals in a
dictionary. Looking things up by index is faster than looking them up by
name.
dictionary. Looking things up by index is faster than looking them up by
name.
>Interesting. How is the index computed? I would have assumed that locals()
>is somehow used, which is a dicht.
They're static indexes assigned at compile time.
within functions. The dictionary isn't the dictionary that's used for
locals but a proxy just for read access.
Ciao,
Marc 'BlackJack' Rintsch
Comment