[Python-ideas] Allow filtered dir built in

Steven D'Aprano steve at pearwood.info
Fri Jun 15 06:40:47 EDT 2018


On Fri, Jun 15, 2018 at 10:10:19AM +0200, Michel Desmoulin wrote:

> Fantastic idea. Would this make sense on var() too ? It's not exactly
> the same usage context.

No. The point of vars() is to return the actual namespace dict used by 
an object. It's not primarily an introspection tool, it is the public 
interface for accessing __dict__ without using the dunder directly.

vars() and dir() have completely different purposes, and they do very 
different things.


-- 
Steve


More information about the Python-ideas mailing list