Module/package hierarchy and its separation from file structure

Peter Schuller peter.schuller at infidyne.com
Wed Jan 30 04:31:16 EST 2008


>> The problem is that we are now back to the identity problem. The class
>> won't actually *BE* org.lib.animal.Monkey.
>
> The usage is the same; it works in all cases once you redefine
> __module__.  Who cares what it really is?

The cases I listed were just examples. My point was that I wanted it
to *be* the right class, to avoid unintended consequences. If I knew
what all those possible consequences were, there would not be a
problem to begin with.

The other follow-up to your E-Mail points out a possible problem for
example. I would not have come up with that, but that does not mean
the effect does not exist. And committing to a solution that "seems to
work", only to break massively for some particular use case in the
future, is exactly why I don't want a "hack" for a solution.

I don't know Python internals enough to state of believe with any
authority wither, let's say, stomping __module__ and hacking
sys.modules would be enough to *truly* do it correctly in a proper way
such that it is entirely transparent. This is why I care about whether
it truly changes the real identity of the class; it's not about
satisfying my particular list of examples (because they *were* just
examples).

> Whatever.  ISTM you came here looking for a particular means and not a
> particular end.

My particular preferred end is to be able to separate file hierarchy
from module hierarchy without causing unforseen consequences. This was
the stated goal all along.

> Python already has the power to meet your stated
> needs, but you won't use that solution because it's "hacky".
> Apparently all you really wanted was the loosened file structure in
> the first place.

Yes, or failing that an alternative that mitigates the problem. And it
*is* hacky, in my opinion, if things break as a result of it (such as
the other poster's inspect example).

-- 
/ Peter Schuller

PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller at infidyne.com>'
Key retrieval: Send an E-Mail to getpgpkey at scode.org
E-Mail: peter.schuller at infidyne.com Web: http://www.scode.org




More information about the Python-list mailing list