Actually the was no circular import since I haven't imported a from b,
but just b from a.
And unfortunately your answer didn't solve the original question,
which is getting the value from the module that imports the current
module.

Or maybe the is a way to include another file and parse it with the
context of the current one, like include statement in PHP?

If there are no ways to do that, then I will just use some
workarounds. At first, I am interested about possibilities.

Regards,
Aidas Bendoraitis aka Archatas

On 3/30/07, Forest Bond <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 30, 2007 at 01:43:41PM +0200, Aidas Bendoraitis wrote:
> >
> > Let's say I have the files main.py, a.py and b.py
> >
> > main.py:
> > -----------
> > x="some local value"
> > import a
> > ...
> >
> >
> > a.py:
> > -----------
> > x="some other local value"
> > import b
> > ...
> >
> >
> > b.py:
> > -----------
> > def test():
> >     print x
> >
> > ----------------------
> > Is it possible to access the x of the module a.py in the module b.py?
> > What would be the functions/statements to make it possible? Or in
> > general, how to access the locals of the importing ( not imported!!!)
> > module?
>
> Well, you have a circular import here that may cause you problems.  Neither
> module could finish loading because it depends on the other being imported 
> which
> depends on the other being imported which depends on the other being imported
> ....
>
> But, this could work:
>
> a.py:
> --------------------------------------------------------------------------------
> x = 'some local value'
> --------------------------------------------------------------------------------
>
> b.py:
> --------------------------------------------------------------------------------
> x = 'some other local value'
>
> def print_a_x():
>     import a
>     print a.x # prints 'some local value'
>
> def print_x():
>     print x # prints 'some other local value'
> --------------------------------------------------------------------------------
>
> Hope this helps.
>
> -Forest
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
>
> iD8DBQFGDPn2RO4fQQdv5AwRApiIAJ9lqLzefjFU8aZMWYunM7aLehOUAwCfV+UU
> 0HQMbDvTGxLvi0phpgn0XOU=
> =Pt2E
> -----END PGP SIGNATURE-----
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to