On Wed, Sep 6, 2017 at 10:26 AM, Guido van Rossum <gu...@python.org> wrote:
>
> So we've seen a real use case for __class__ assignment: deprecating things on 
> access. That use case could also be solved if modules natively supported 
> defining __getattr__ (with the same "only used if attribute not found 
> otherwise" semantics as it has on classes), but it couldn't be solved using 
> @property (or at least it would be quite hacky).
>
> Is there a real use case for @property? Otherwise, if we're going to mess 
> with module's getattro, it makes more sense to add __getattr__, which would 
> have made Nathaniel's use case somewhat simpler. (Except for the __dir__ 
> thing -- what else might we need?)
> --
> --Guido van Rossum (python.org/~guido)


I think a more natural way for the __dir__ problem would be to update
module_dir() in moduleobject.c to check if __all__ is defined and then
just return that list if it is defined.  I think that would be a
friendlier default for __dir__ anyway.

Cody
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to