Re: NB question on global/local variables in functions

2006-07-17 Thread Bruno Desthuilliers
Wolfgang wrote: > Hi all, > > I've started to write some functions but I have some problems with > common variables in that functions. > > So I have some variables which should be accessible by all my functions > but not accessible by the rest of my code. How can I do this? You can use a closure

Re: NB question on global/local variables in functions

2006-07-15 Thread Fredrik Lundh
Wolfgang wrote: >> First, avoid "from function import *" as it pollutes your namespace. Either >> import specific symbols or just the module: >> >> from function import fun, fun1 >> import function > > thanks for the hint! But what is the difference between > from module import * >

Re: NB question on global/local variables in functions

2006-07-15 Thread Wolfgang
Thanks! I've learned a lot today! Wolfgang -- http://mail.python.org/mailman/listinfo/python-list

Re: NB question on global/local variables in functions

2006-07-15 Thread skip
Wolfgang> thanks for the hint! But what is the difference between Wolfgang> from module import * Wolfgang> and Wolfgang> import module Wolfgang> ? Try it and see. I happen to have a.py laying about: import atexit def work(): print "whew! work is hard" d

Re: NB question on global/local variables in functions

2006-07-15 Thread Wolfgang
Wolfgang schrieb: >> First, avoid "from function import *" as it pollutes your namespace. Either >> import specific symbols or just the module: >> >> from function import fun, fun1 >> import function > > thanks for the hint! But what is the difference between > from module import * >

Re: NB question on global/local variables in functions

2006-07-15 Thread Wolfgang
> > First, avoid "from function import *" as it pollutes your namespace. Either > import specific symbols or just the module: > > from function import fun, fun1 > import function thanks for the hint! But what is the difference between from module import * and import module ? >

Re: NB question on global/local variables in functions

2006-07-15 Thread skip
Wolfgang> So I have some variables which should be accessible by all my Wolfgang> functions but not accessible by the rest of my code. How can I Wolfgang> do this? Wolfgang> ###function.py: Wolfgang> c1=123.0 Wolfgang> c2=134.0 Wolfgang> def fun(temp): Wolfgang>

NB question on global/local variables in functions

2006-07-15 Thread Wolfgang
Hi all, I've started to write some functions but I have some problems with common variables in that functions. So I have some variables which should be accessible by all my functions but not accessible by the rest of my code. How can I do this? Thanks Wolfgang ###function.py: c1=123.0 c2=134