On Oct 16, 2:13 pm, "Tomasz Nazar" <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 16, 2008 at 8:55 PM, Mike Orr <[EMAIL PROTECTED]> wrote:
>
> > On Thu, Oct 16, 2008 at 4:12 AM, Tomasz Nazar <[EMAIL PROTECTED]> wrote:
> >> Cyclic dependencies do not work just that simple. "Cyclic" imports
> >> unfortunately have to placed inside a method - not at the top of
> >> module.
>
> > Importing in a function is the best way to deal with cyclic imports,
> > yes.  Although even better is to avoid them entirely.
>
> Yes. Of course it is :)
> It's a matter of taste. I don't like having imports inside a method,
> though sometimes that's the only way..
>
> > Why do conference and participant have to import each other?  Neither
> > is using the other as its base class.  If  you have a tight
> > relationship between two classes like this, it's a good reason to put
> > them in the same module.
>
> That was just a fake example to test if that works.
> In real examples I have few such situations and I won't elaborate on that.
> I feel sorry that Python import works this way. It's just the way it
> is.. So I look for best method to work round that.
> I do not have and don't want to design my classes and modules in a
> tree like graph. IMHO Python forces me here too much - and my nature
> is to resist when pushed too much ;)

I get tripped up by cyclic imports once in a while, but I think once
you understand how imports work in general, it's really no big deal to
work with/around their quirks. Every language has these kinds of
quirks--I'm pretty sure it's unavoidable.

I found this article helpful for coming to terms with how imports work
in Python:

http://effbot.org/zone/import-confusion.htm

-wlb

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

Reply via email to