Re: [Python-Dev] introducing __dir__?

2006-07-07 Thread Guido van Rossum
+1 here too. This could be added easily to Python 2.6.

--Guido

On 7/7/06, Nick Coghlan [EMAIL PROTECTED] wrote:
 Fred L. Drake, Jr. wrote:
  On Thursday 06 July 2006 13:22, tomer filiba wrote:
my suggestion is simple -- replace this mechanism with a __dir__ -
a special method that returns the list of attributes of the object.
   
rationale:
* remove deprecated __methods__, etc.
* symmetry -- just like hex() calls __hex__, etc.
* __methods__ and __members__ are lists rather than callable
objects, which means they cannot be updated on-demand
 
  +1

 +1 here, too.

 It would also allow objects which override __getattribute__ and/or __getattr__
 to make dir() provide a sane answer (or raise an exception to indicate that a
 sane answer isn't possible). (This was something that actually came up when
 trying to implement a namespace object that *didn't* automatically fall back
 to its class namespace for Python level attribute access)

 For backwards compatibility, dir() could still fall back to the current
 mechanism if __dir__ isn't found.

 Cheers,
 Nick.

 --
 Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
 ---
  http://www.boredomandlaziness.org
 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe: 
 http://mail.python.org/mailman/options/python-dev/guido%40python.org



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] introducing __dir__?

2006-07-06 Thread Fred L. Drake, Jr.
On Thursday 06 July 2006 13:22, tomer filiba wrote:
  my suggestion is simple -- replace this mechanism with a __dir__ -
  a special method that returns the list of attributes of the object.
 
  rationale:
  * remove deprecated __methods__, etc.
  * symmetry -- just like hex() calls __hex__, etc.
  * __methods__ and __members__ are lists rather than callable
  objects, which means they cannot be updated on-demand

+1


  -Fred

-- 
Fred L. Drake, Jr.   fdrake at acm.org
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com