>> 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
; > 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
can,please show me the doc for python's object scope.
--
http://mail.python.org/mailman/listinfo/python-list
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
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)
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
[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
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
"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
"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
>
> 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
[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
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
[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
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()
15 matches
Mail list logo