Re: [Python-Dev] dir() and __all__

2008-02-21 Thread Raymond Hettinger
[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

Re: [Python-Dev] dir() and __all__

2008-02-21 Thread Benjamin
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 >

Re: [Python-Dev] dir() and __all__

2008-02-15 Thread Thomas Wouters
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

Re: [Python-Dev] dir() and __all__

2008-02-15 Thread Aahz
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.

Re: [Python-Dev] dir() and __all__

2008-02-15 Thread Guido van Rossum
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

Re: [Python-Dev] dir() and __all__

2008-02-15 Thread Raymond Hettinger
[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

Re: [Python-Dev] dir() and __all__

2008-02-15 Thread Steve Holden
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,

Re: [Python-Dev] dir() and __all__

2008-02-15 Thread skip
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

Re: [Python-Dev] dir() and __all__

2008-02-15 Thread Guido van Rossum
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__', > '_

[Python-Dev] dir() and __all__

2008-02-15 Thread Raymond Hettinger
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']