Re: creating variable in root namespace from module

2006-03-10 Thread MakaMaka
Ok, but it seems to be working exactly as I need it to right now under win32. I'll try it on linux. Can you suggest an alternative method? Or suggest when this won't work? Thanks, -Justin -- http://mail.python.org/mailman/listinfo/python-list

Re: creating variable in root namespace from module

2006-03-10 Thread Duncan Booth
MakaMaka wrote: > Ok, I figured it out. Thanks for your help guys. If anybody else is > searching this group looking for the answer, you want the > sys._getframe() function. > > sys._getframe(1).f_locals['a'] = 1 > > if you put the above in a function in a module, it creates a variable > 'a' i

Re: creating variable in root namespace from module

2006-03-10 Thread MakaMaka
Ok, I figured it out. Thanks for your help guys. If anybody else is searching this group looking for the answer, you want the sys._getframe() function. sys._getframe(1).f_locals['a'] = 1 if you put the above in a function in a module, it creates a variable 'a' in the namespace of whatever calls

Re: creating variable in root namespace from module

2006-03-10 Thread MakaMaka
Steve, I think I actually need to get the caller's local namespace. How do I do that using sys? I read the documentation and can't find anything specific. For example, if I have module A and it imports module B, I want module B to add variables to A's global namespace. Python has to store this

Re: creating variable in root namespace from module

2006-03-10 Thread Steve Holden
MakaMaka wrote: > Hi again, > Steve- > I'm trying to use python to model reliability. Basically, I want to > read an XML file in that defines a bunch of variables, that are then > accessible from the python interpreter. For example: > import reliability > > reliability.read_xml("c:\\somefile.xml

Re: creating variable in root namespace from module

2006-03-10 Thread MakaMaka
Hi again, Steve- I'm trying to use python to model reliability. Basically, I want to read an XML file in that defines a bunch of variables, that are then accessible from the python interpreter. For example: import reliability reliability.read_xml("c:\\somefile.xml") #<== defines x1, x2, x3 resu

Re: creating variable in root namespace from module

2006-03-10 Thread Duncan Booth
MakaMaka wrote: > I have a scope related question that I haven't been able to find an > answer to anywhere. Is there a way to have a function in an imported > module add variables to the scope of the calling script? Basically, > can I have the following: > > #root.py > import some_module.py >

Re: creating variable in root namespace from module

2006-03-10 Thread Steve Holden
MakaMaka wrote: > Hi, > I have a scope related question that I haven't been able to find an > answer to anywhere. Is there a way to have a function in an imported > module add variables to the scope of the calling script? Basically, > can I have the following: > > #root.py > import some_module.p

creating variable in root namespace from module

2006-03-09 Thread MakaMaka
Hi, I have a scope related question that I haven't been able to find an answer to anywhere. Is there a way to have a function in an imported module add variables to the scope of the calling script? Basically, can I have the following: #root.py import some_module.py some_module.afunction() # <==