Python2.2 doesn't give members of a list

Paul Boddie paul at boddie.net
Mon Aug 13 05:02:49 EDT 2001


"Tim Peters" <tim.one at home.com> wrote in message news:<mailman.997581501.6670.python-list at python.org>...
> [Tim]
> > although-nothing-can-make-everyone-happy-ly y'rs  - tim
> 
> [Paul Boddie]
> > Absolutely not!
> 
> LOL -- "absolutely not" *what*?

I meant that absolutely nothing-can-make-everyone-happy. ;-)

> It's absolutely not more consistent, absolutely not more predictable,
> absolutely not an incompatibility, I absolutely should not look at hacking
> backward-compatibility crud back into dir(), or it's absolutely not the case
> that nothing can make everyone happy?

Nothing can, but we'd surely be *content* to see this change. ;-)

> > Perhaps there should be a well-known and widely published way of doing
> > this kind of thing, but dir is a well-known function. It's a shame
> > about dir([])...
> 
> dir() may be well-known, but what it does isn't.  It was originally added
> with dir(module) in mind, and nothing more than that

[...]

Yes, but I think people really like the idea of being able to use it
like UNIX's ls command (or DOS's dir command, obviously) for a given
namespace. Again it comes down to one particular interpretation of
consistency: dir returns variables and functions (and classes) for
modules, so why not have it return attributes and methods for objects?
It already does so for classes (class attributes and unbound methods),
but in order to justify the same for objects, we need to briefly
consider what modules are... before people like me start to claim that
modules are more like objects than classes. ;-)

> I like Guido's idea of having it return more instead of less, though.  In
> any case, introspective needs vary too much by context to hope that a single
> simple function will make everyone happy -- or even anyone happy all the
> time.

Isn't that Barnum's Law? :-)

> and-it-is-a-shame-about-dir([])-otherwise-ly y'rs  - tim

Yes, but on this subject I'm just being an "agent provocateur" - I
don't use dir that much myself. But then perhaps that's due to its
inconsistent behaviour...

Paul



More information about the Python-list mailing list