[Benjamin]
> Are you proposing just a list those modules
> or all module objects?
The idea is dead. Guido specified that the
dir() function returns a list of names for
which hasattr() will succeed.
I only brought this up because a colleague was
using dir() on modules to find-out about the API
On Feb 15, 9:18 pm, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote:
> [Raymond]
>
> >> Should dir(module) use __all__ when defined?
>
> [GvR]
>
> > It's not consistent with what dir() of a class or instance does though.
>
> > -1.
>
> Perhaps there is another solution. Have dir() exclude objects
>
On Sat, Feb 16, 2008 at 4:18 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> [Raymond]
> >> Should dir(module) use __all__ when defined?
>
> [GvR]
> > It's not consistent with what dir() of a class or instance does though.
> >
> > -1.
>
> Perhaps there is another solution. Have dir() exclude ob
On Fri, Feb 15, 2008, Raymond Hettinger wrote:
>
> [Raymond]
> >> Should dir(module) use __all__ when defined?
>
> [GvR]
> > It's not consistent with what dir() of a class or instance does though.
> >
> > -1.
>
> Perhaps there is another solution. Have dir() exclude objects which
> are modules.
I'm not sure which use case you're after here, but I doubt it's what
dir() was designed to do. dir() is meant to attempt to give you all
attributes for which getattr() will succeed, barring dynamic overrides
of __getattr[ibute]__.
On Fri, Feb 15, 2008 at 7:18 PM, Raymond Hettinger <[EMAIL PROTECTE
[Raymond]
>> Should dir(module) use __all__ when defined?
[GvR]
> It's not consistent with what dir() of a class or instance does though.
>
> -1.
Perhaps there is another solution. Have dir() exclude objects
which are modules. For example, dir(logging) would exclude
sys, os, types, time, string
Maybe classes should have __all__ too, then the people who complain
about not being able to declare private class attributes could be
pointed at that.
regards
Steve
Guido van Rossum wrote:
> It's not consistent with what dir() of a class or instance does though.
>
> -1.
>
> On Fri, Feb 15,
Guido> It's not consistent with what dir() of a class or instance does
Guido> though. -1.
Agreed. The only official use I'm aware of is to restrict what is imported
when you execute
from mod import *
Raymond> >>> Queue.__all__
Raymond> ['Empty', 'Full', 'Queue', 'PriorityQ
It's not consistent with what dir() of a class or instance does though.
-1.
On Fri, Feb 15, 2008 at 5:30 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> Should dir(module) use __all__ when defined?
>
> >>> dir(Queue)
> ['Empty', 'Full', 'LifoQueue', 'PriorityQueue', 'Queue', '__all__',
> '_
Should dir(module) use __all__ when defined?
>>> dir(Queue)
['Empty', 'Full', 'LifoQueue', 'PriorityQueue', 'Queue', '__all__',
'__builtins__', '__doc__', '__file__', '__name__', '__package__', '_time',
'deque', 'heapq']
>>> Queue.__all__
['Empty', 'Full', 'Queue', 'PriorityQueue', 'LifoQueue']
10 matches
Mail list logo