Re: [Tutor] imported module/global

2007-04-16 Thread Andreas Kostyrka
* Luke Paireepinart <[EMAIL PROTECTED]> [070416 20:27]: > Andreas Kostyrka wrote: > >OTOH, module globals are seldom used, and usually frowned on. E.g. the > >python2.5 standard lib (>200K lines, 584 py files), uses exactly 104 > >distinct global statements. > > > >[EMAIL PROTECTED]:/usr/lib/python

Re: [Tutor] imported module/global

2007-04-16 Thread Luke Paireepinart
Andreas Kostyrka wrote: > OTOH, module globals are seldom used, and usually frowned on. E.g. the > python2.5 standard lib (>200K lines, 584 py files), uses exactly 104 > distinct global statements. > > [EMAIL PROTECTED]:/usr/lib/python2.5> grep -r "^[ \t]*global " . | sed 's/[ > \t][ \t]*/ /' | so

Re: [Tutor] imported module/global

2007-04-15 Thread Andreas Kostyrka
* Cecilia Alm <[EMAIL PROTECTED]> [070416 07:45]: > OK, apologies if my terminology and wording was unfortunate and unclear. > > (Setting aside for now if this is preferred practice or not) In > regards to modifying a global mutable list/dictionary (for example > appending to a global list), the n

Re: [Tutor] imported module/global

2007-04-15 Thread Cecilia Alm
OK, apologies if my terminology and wording was unfortunate and unclear. (Setting aside for now if this is preferred practice or not) In regards to modifying a global mutable list/dictionary (for example appending to a global list), the name does not need defined within the local namespace, right?

Re: [Tutor] imported module/global

2007-04-15 Thread Alan Gauld
"Cecilia Alm" <[EMAIL PROTECTED]> wrote > Hm, I'm confused by your post. Within the global's module, the > "global > z" syntax works for bothh modifying and accessing, and makes the > code > clearer to read in my opinion. You seem to be confused about the role of the global keyword. It is pure

Re: [Tutor] imported module/global

2007-04-15 Thread Cecilia Alm
> difficult to understand, but sometimes it is useful. For example you > might have a shared configuration module, or a module might have > configuration parameters that can be changed. Yes, this is exactly the case I got. (Otherwise, I'd rather avoid "globals" all together.) Thanks for your resp

Re: [Tutor] imported module/global

2007-04-15 Thread Cecilia Alm
Well, your example still seems to be about accessing or modifying a global variable *within* its own module. Then it can't hurt to prepend 'global' even when just accessing, right? (even if not *necessary*, one could argue make the code clearer). But, my question related specifically to another ca

Re: [Tutor] imported module/global

2007-04-15 Thread Kent Johnson
Cecilia Alm wrote: >> attributes of the module object. When you import the module in another >> module, you gain access to the imported module's attributes using the >> normal dot notation for attribute access. > > By " attribute access", you also mean modifying/assigning to, right? Yes, you can

Re: [Tutor] imported module/global

2007-04-15 Thread Andreas Kostyrka
* Cecilia Alm <[EMAIL PROTECTED]> [070415 23:19]: > 2007/4/15, Andreas Kostyrka <[EMAIL PROTECTED]>: > >* Cecilia Alm <[EMAIL PROTECTED]> [070415 18:21]: > >> If a module "x" imports module "y" with a global variable "z", then > >> this global can be referred or assigned to in "x" with the syntax >

Re: [Tutor] imported module/global

2007-04-15 Thread Cecilia Alm
> attributes of the module object. When you import the module in another > module, you gain access to the imported module's attributes using the > normal dot notation for attribute access. By " attribute access", you also mean modifying/assigning to, right?

Re: [Tutor] imported module/global

2007-04-15 Thread Cecilia Alm
2007/4/15, Andreas Kostyrka <[EMAIL PROTECTED]>: > * Cecilia Alm <[EMAIL PROTECTED]> [070415 18:21]: > > If a module "x" imports module "y" with a global variable "z", then > > this global can be referred or assigned to in "x" with the syntax > > "y.z" (no "global" keyword preceding) and changes ar

Re: [Tutor] imported module/global

2007-04-15 Thread Andreas Kostyrka
* Cecilia Alm <[EMAIL PROTECTED]> [070415 18:21]: > If a module "x" imports module "y" with a global variable "z", then > this global can be referred or assigned to in "x" with the syntax > "y.z" (no "global" keyword preceding) and changes are accessible to > class methods in "y" referring to "glob

Re: [Tutor] imported module/global

2007-04-15 Thread Kent Johnson
Cecilia Alm wrote: > If a module "x" imports module "y" with a global variable "z", then > this global can be referred or assigned to in "x" with the syntax > "y.z" (no "global" keyword preceding) and changes are accessible to > class methods in "y" referring to "global z". Yes. > I assume this i

[Tutor] imported module/global

2007-04-15 Thread Cecilia Alm
If a module "x" imports module "y" with a global variable "z", then this global can be referred or assigned to in "x" with the syntax "y.z" (no "global" keyword preceding) and changes are accessible to class methods in "y" referring to "global z". I assume this is related to namespace/scope? Than