Global variables for python applications

Rhodri James rhodri at wildebst.demon.co.uk
Mon May 17 18:54:38 EDT 2010


On Mon, 17 May 2010 05:29:20 +0100, Steven D'Aprano  
<steven at remove.this.cybersource.com.au> wrote:

> On Sun, 16 May 2010 18:57:15 -0700, John Nagle wrote:
>
>> James Mills wrote:
>>> The only place global variables are considered somewhat "acceptable"
>>> are as constants in a module shared as a static value.
>>
>>     Python really ought to have named constants.
>
> +1
>
> Unfortunately, it will most likely require new syntax, and semantics.
> While the concept of a constant is pretty straightforward for immutable
> types like ints and strings, what about mutable types?
>
> And then there's the moratorium, so even if we had agreement on semantics
> and syntax, and a patch, it couldn't be deployed for a few years.

Careful, you're reconflating two concepts that John separated: mutability  
of an object and binding of a name.  I'm on the side of 'named constant'  
meaning 'this name (in this scope) is bound to this object and cannot be  
rebound.'  That would cover most of the cases people care about, and the  
gotchas are essentially the same as with default arguments.

But yes, it would require new syntax.

-- 
Rhodri James *-* Wildebeeste Herder to the Masses



More information about the Python-list mailing list