Carl Banks <[EMAIL PROTECTED]> writes:

> On Jan 25, 6:45 pm, Ben Finney <[EMAIL PROTECTED]>
> wrote:
> > "Gabriel Genellina" <[EMAIL PROTECTED]> writes:
> > > You can also put, in animal/__init__.py:
> > > from monkey import Monkey
> > > and now you can refer to it as org.lib.animal.Monkey, but keep the
> > > implementation of Monkey class and all related stuff into
> > > .../animal/monkey.py
> >
> > This (as far as I can understand) is exactly the solution the
> > original poster desired to "shoot down", for reasons I still don't
> > understand.
> 
> The solution is to modify the class's __module__ attribute as well as
> importing it, as I've already pointed out:
> 
> from org.lib.animal.monkey import Monkey
> Monkey.__module__ = 'org.lib.animal'

Thanks, that makes it clear.

> This should be enough to satisfy the OP's requirements, at least for
> classes, without softening the one-to-one module-to-file
> relationship, or using "hacks".
> 
> In fact, I'd say this is good practice.

I've not seen that before, but it seems an elegant way to address what
the OP is asking for.

-- 
 \            "Madness is rare in individuals, but in groups, parties, |
  `\         nations and ages it is the rule."  -- Friedrich Nietzsche |
_o__)                                                                  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to