Importing a class without knowing the module
mwm at mired.org
Fri Nov 18 20:01:08 CET 2005
aleax at mail.comcast.net (Alex Martelli) writes:
> Mike Meyer <mwm at mired.org> wrote:
>> A classes __module__ attribute doesn't always tell you the name of the
>> module - or at least, not a name that would be usefull for the the OPs
>> use case. That's the case where you don't have the module name. The
> How do you arrange a module so that its classes' __module__ attributes
> don't tell you the name of the module "that would be useful", yet the
> module's __file__ DOES give you information that you can usefully
> process, heuristically I assume, to infer a module name that IS useful?
So what module name do you import if C.__module__ is __main__?
> I just don't see it, which of course doesn't mean it can't be done, with
> sufficient evil ingenuity. But since you're the one arguing that this
> case is important enough to be worth dwelling on,
I'm not dwelling on it, you are. All I did was recommend using the
module name if you had one, and if not then the file name was your
best bet. You chose to ignore part of my statement to focus on the
part you disagreed with, because you thought what I had suggested in
the first place was a better idea. I pointed out this oversight on
your part, and you've been dwelling on it ever since.
Frankly, I thought you were brighter than that, have no idea why
you're acting like this, and frankly don't think you need a tutor. I
figured this out by fooling around with the interpreter before posting
in the first place, you certainly know enough to do the same.
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list