On Wednesday 06 October 2010, it occurred to Dave Angel to exclaim:
> On 2:59 PM, Thomas Jollans wrote:
> >
> > % cat a.py
> > foo = 'Meh.'
> > import b
> >
> > % cat b.py
> > from a import foo
> >
> > print(foo)
> >
> > % python a.py
> > Meh.
> > %
>
> But there are now two modules containing
On 2:59 PM, Thomas Jollans wrote:
% cat a.py
foo = 'Meh.'
import b
% cat b.py
from a import foo
print(foo)
% python a.py
Meh.
%
But there are now two modules containing separate items foo, one is
called __main__, and the other is called a.
The former is the script you ran, and the la
Thanks a million, runpy is exactly what I was looking for!
I will send you a link to what I'm using it for when it's done. Then you'll
understand ;)
-- Jonas
On Tue, Oct 5, 2010 at 1:06 PM, Thomas Jollans wrote:
> On Tuesday 05 October 2010, it occurred to Jonas Galvez to exclaim:
> > Is there
On Tuesday 05 October 2010, it occurred to Jonas Galvez to exclaim:
> Is there a way to "inject" something into a module right before it's
> loaded?
>
> For instance, a.py defines "foo". b.py print()s "foo".
>
> I want to load b.py into a.py, but I need to let b.py know about "foo"
> before it ca
Jonas Galvez wrote:
Is there a way to "inject" something into a module right before it's
loaded?
For instance, a.py defines "foo". b.py print()s "foo".
I want to load b.py into a.py, but I need to let b.py know about "foo"
before it can execute.
Is this any way to achieve this?
-- Jonas
Is there a way to "inject" something into a module right before it's loaded?
For instance, a.py defines "foo". b.py print()s "foo".
I want to load b.py into a.py, but I need to let b.py know about "foo"
before it can execute.
Is this any way to achieve this?
-- Jonas
--
http://mail.python.org/