Re: object scope

2008-01-20 Thread Gabriel Genellina
>> local name. > > Thank you. Does python have so-called 'block scope' object? > or if you can,please show me the doc for python's object scope. See http://docs.python.org/ref/naming.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: object scope

2008-01-20 Thread George Sakkis
; > local name. > > Thank you. Does python have so-called 'block scope' object? No, it doesn't; in most cases that you may care, a name's scope is either local or global*. > or if you can,please show me the doc for python's object scope. http://www.network-the

Re: object scope

2008-01-20 Thread J. Peng
can,please show me the doc for python's object scope. -- http://mail.python.org/mailman/listinfo/python-list

Re: object scope

2008-01-20 Thread J. Peng
J. Peng 写道: > Please see the code below,what's the scope for object "name"? > I thought it should be located in the while block, but it seems not > really,it can be accessed out of while (the db[name] statement).Thanks > in advance. > > sorry the before code seems be disordered,re-posted it. db

object scope

2008-01-20 Thread J. Peng
Please see the code below,what's the scope for object "name"? I thought it should be located in the while block, but it seems not really,it can be accessed out of while (the db[name] statement).Thanks in advance. db = {} def newuser(): prompt = 'login desired: ' while 1: name = raw_input(prompt)

Re: Help on object scope?

2007-02-27 Thread Bart Ogryczak
On Feb 25, 10:25 pm, [EMAIL PROTECTED] wrote: > Hello everybody, > > I have a (hopefully) simple question about scoping in python. I have a > program written as a package, with two files of interest. The two > files are /p.py and /lib/q.py > > My file p.py looks like this: > > --- > > from lib impo

Re: Help on object scope?

2007-02-27 Thread Jussi Salmela
[EMAIL PROTECTED] kirjoitti: > > global names seemed to be the best idea. The only problem is now I > have to type common.r.t instead of just r.t. If I put common in the / > lib directory, it is even worse and I have to type lib.common.r.t. I > like that it is explicit and perhaps this is the Pyt

Re: Help on object scope?

2007-02-27 Thread bmaron2
On Feb 26, 1:16 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Mon, 26 Feb 2007 07:54:12 +0200, "Hendrik van Rooyen" > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > > from param import * > > "from <> import *" (or any "from <> import ..." variant) is NOT th

Re: Help on object scope?

2007-02-26 Thread Duncan Booth
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > You can interact just fine, just qualify the objects with the module > names. So in q, you need to use p.r instead of just r. No. When p.py is being run as a script, the module you need to access is __main__. Much better to put the globals into a

Re: Help on object scope?

2007-02-25 Thread Hendrik van Rooyen
"hg" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > Hello everybody, > > > > I have a (hopefully) simple question about scoping in python. I have a > > program written as a package, with two files of interest. The two > > files are /p.py and /lib/q.py Make a third file for all th

Re: Help on object scope?

2007-02-25 Thread Diez B. Roggisch
> > Thank you for the advice, but that seems a bit unwieldy. My code will > have about 10 of these global objects, all of which interact with > eachother. It seems silly to have to pass 10 parameters around to each > instance I work with. I hope there is a smarter way to do it, or > perhaps someon

Re: Help on object scope?

2007-02-25 Thread Ben Finney
[EMAIL PROTECTED] writes: > My code will have about 10 of these global objects, all of which > interact with eachother. It seems silly to have to pass 10 > parameters around to each instance I work with. Yes. A better solution would be to put them inside a module, and import that module. Then the

Re: Help on object scope?

2007-02-25 Thread bmaron2
On Feb 25, 9:37 am, hg <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hello everybody, > > > I have a (hopefully) simple question about scoping in python. I have a > > program written as a package, with two files of interest. The two > > files are /p.py and /lib/q.py > > > My file p.py l

Re: Help on object scope?

2007-02-25 Thread hg
[EMAIL PROTECTED] wrote: > Hello everybody, > > I have a (hopefully) simple question about scoping in python. I have a > program written as a package, with two files of interest. The two > files are /p.py and /lib/q.py > > My file p.py looks like this: > > --- > > from lib import q > > def ma

Help on object scope?

2007-02-25 Thread bmaron2
Hello everybody, I have a (hopefully) simple question about scoping in python. I have a program written as a package, with two files of interest. The two files are /p.py and /lib/q.py My file p.py looks like this: --- from lib import q def main(): global r r = q.object1() s = q.object2()