Re: Newbie namespace question

2004-12-24 Thread Alex Martelli
Peter Hansen <[EMAIL PROTECTED]> wrote: > I'm not sure what you think that does, but I don't > think it does it. QOTW +1 !!! Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie namespace question

2004-12-23 Thread Nick Coghlan
Brandon wrote: I did the constructor thing and just didn't like it, it didn't feel clean (I know, I know and monkeying with __builtin__ is?) As for global, that will just make it modlue-level global (I think?) and I have this reference in multiple modules. I think I tried it already, but I can't r

Re: Newbie namespace question

2004-12-23 Thread Brandon
I did the constructor thing and just didn't like it, it didn't feel clean (I know, I know and monkeying with __builtin__ is?) As for global, that will just make it modlue-level global (I think?) and I have this reference in multiple modules. I think I tried it already, but I can't remember for su

Re: Newbie namespace question

2004-12-22 Thread Nick Coghlan
Brandon wrote: Peter, You're correct about the bug. I did need a 'self' parm... I was just winging the example because the actual code is pretty large. I'm using google groups for my posting and it didn't carry spaces through (I did use spaces and not tabs). The "fix" or workaround was to import

Re: Newbie namespace question

2004-12-22 Thread Brandon
Peter, You're correct about the bug. I did need a 'self' parm... I was just winging the example because the actual code is pretty large. I'm using google groups for my posting and it didn't carry spaces through (I did use spaces and not tabs). The "fix" or workaround was to import __builtin__

Re: Newbie namespace question

2004-12-22 Thread Peter Hansen
Brandon wrote: Thanks, that worked to get me past the "problem". Did you see my post regarding my issue? I just know that there's a "Python way" to resolve my issue, so if anyone has a better way, I'm really interested. Not only does it feel like a hack, it looks like one too! Even worse! If you

Re: Newbie namespace question

2004-12-22 Thread Peter Hansen
deelan wrote: i believe that to avoid circular refs errors remember you can lazy-import, for example here i'm importing the email package: m = __import__('email') m check help(__import__) for futher details. I'm not sure what you think that does, but I don't think it does it. The code you show

Re: Newbie namespace question

2004-12-22 Thread Jeff Shannon
[EMAIL PROTECTED] wrote: Now, in jdbc.py I have #jdbc.py class DataSource: def __init__(self, servername): self.servername = servername def create(name, connectionInfo, etc): #Call the IBM supplied WebSphere config object AdminConfig.create('DataSource') Run it and get a name error, which, makes se

Re: Newbie namespace question

2004-12-22 Thread deelan
[EMAIL PROTECTED] wrote: (...) Run it and get a name error, which, makes sense. If I try to use the standard import solution as deelan suggests I have a circular reference on the imports and I get an error that it can't import class DataSource (presumbably because it hasn't gotten far enough throug

Re: Newbie namespace question

2004-12-22 Thread Brandon
Thanks, that worked to get me past the "problem". Did you see my post regarding my issue? I just know that there's a "Python way" to resolve my issue, so if anyone has a better way, I'm really interested. Not only does it feel like a hack, it looks like one too! Even worse! -- http://mail.pyth

Re: Newbie namespace question

2004-12-22 Thread Peter Hansen
Steve Holden wrote: then in some other module (and here specifically in the interactive interpreter) you can bind a value to "myname" in __builtins__ and it will be seen by mymod.py when it's imported: >>> __builtins__.myname = "MyValue" Steve's basic premise is correct, but he's chosen the wro

Re: Newbie namespace question

2004-12-22 Thread Brandon
And I just realized that Jython doesn't support the __builtins__ variable... :( -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie namespace question

2004-12-22 Thread [EMAIL PROTECTED]
Here's my situation, I've created some scripts to configure WebSphere and the WAS scripting engine assigns the variable AdminConfig to a Java object. I have created classes that wrap the AdminConfig settings, simplifying the interface for those who want to script their server installs. At the com

Re: Newbie namespace question

2004-12-22 Thread Steve Holden
[EMAIL PROTECTED] wrote: I have a variable that I want to make global across all modules, i.e. I want it added to the builtin namespace. Is there a way to do this? Of course: you can do *anything* in Python. I'm not sure this is to be recommended, but since you ask ... if you have # mymod.py pri

Re: Newbie namespace question

2004-12-22 Thread deelan
[EMAIL PROTECTED] wrote: I have a variable that I want to make global across all modules, i.e. I want it added to the builtin namespace. Is there a way to do this? i would not pollute built-ins namespace. how about: ### a.py FOO = "I'm a global foo!" ### b.py import a print a.FOO HTH, deelan -- @p

Newbie namespace question

2004-12-22 Thread [EMAIL PROTECTED]
I have a variable that I want to make global across all modules, i.e. I want it added to the builtin namespace. Is there a way to do this? -- http://mail.python.org/mailman/listinfo/python-list