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
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 *
>
Thanks! I've learned a lot today!
Wolfgang
--
http://mail.python.org/mailman/listinfo/python-list
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
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 *
>
>
> 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
?
>
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>