Importing a class without knowing the module

Alex Martelli aleax at mail.comcast.net
Fri Nov 18 18:55:42 EST 2005


Mike Meyer <mwm at mired.org> wrote:
   ...
> I suggested using the module, and mentioned that he might not have a
> better choice than to use __file__ anyway. You overlooked the mention
> of __module__ to complain that __file__ wasn't his best choice,
> because he could use __module__. All I did was point out what you
> overlooked, and have been answering your questions about it ever

Sorry to have given the impression that I overlooked something -- I
didn't KNOW whether I had, which is why I checked back with you about
it, but apparently I hadn't.

> since. If you don't think __file__ is such a good idea, you should
> have said so in the first place.

And I did!  My exact words in my first post to this thread were "I think
that using the class's __module__ rather than __file__ should be what
you want" -- a pretty clear indication that I don't think using __file__
is a hot idea, don't you think?

> Instead, you asked questions about

About what would be the cases where the module's name was not available,
as you had claimed it could be; turns out that you haven't given a
single example yet, just one (__main__) where the module name is
perfectly available, though it may not be *useful* (and there's no
special reason to guess that the *file*'s name would be any use either).

> it. Trying to help you out, I answered them. If trying to help someone
> who seems to be having trouble understanding an issue is "dwelling on
> the issue", well, I'm glad we have a newsgroup full of people who
> dwell on issues.

You did help me to better understand some of the roots of your many
mistaken assertions in this thread, from your first "How about adding
Foo.__file__" proposal onwards, yes -- thank you.  However, I am now
reasonably convinced that your attempt to *defend*, at some level, those
assertions, appear to have no sound technical basis, just a
defensiveness that (in my mind) justifies the use of the word
"dwelling".  But we do fully agree that trying to be helpful, per se, is
never inherently blameworthy, whether one succeeds or fails in the
attempt -- so, thanks for your many (and mostly better based than this
one) attempts to be of help to c.l.py posters.


Alex



More information about the Python-list mailing list