some import / namespace questions
steve at holdenweb.com
Thu Aug 9 02:02:33 CEST 2007
stef mientki wrote:
> Marc 'BlackJack' Rintsch wrote:
>> On Wed, 08 Aug 2007 17:11:19 +0200, stef mientki wrote:
>>> Now it's not possible to import in the existing modules the main plugin,
>>> from Main_User import *
>>> because this will start the infinite loop.
>> Which means there's code at the module level.
>> Tell the users to put that
>> into a function, then you can import the module without executing this
>> main loop.
> ok, I'll do that for the user (the user writes in another language),
> and indeed it works,
> but has one disadavantage ... see below
>> And don't do a * import because your users might use names that the
>> importing module uses already and which would get replaced by the * import.
> Yes that's a principal problem with this program, for which I've no
> (simple) solution.
> I'm simulating a microprocessor language here, where "globality" is an
> essential part of the language.
> So I'll have to stick to import *, (although I'm aware it's not a good
> programming method, especially in user plug-ins)
> and now the problem is that I get a warning that import * is only
> allowed at the module level :-(
> But despite the warning it's still working. ;-)
If you read the docs on the warnings module you should be able to
suppress that message.
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
More information about the Python-list