[Python-ideas] Add __parent__ to all classes, functions, and modules

Neil Girdhar mistersheik at gmail.com
Sun Oct 5 22:51:44 CEST 2014


On Sun, Oct 5, 2014 at 2:09 PM, Benjamin Peterson <benjamin at python.org>
wrote:

> Neil Girdhar <mistersheik at ...> writes:
>
> >
> > Many classes, functions, and modules are defined within the context of
> another class, function, or module thereby forming a mathematical forest of
> declarations.  It is possible to walk the descendants using __dict__ (for
> classes and modules), but not the ancestors.  I propose adding __parent__
> that would be filled at the same time that __qualname__ is filled in.
>
> This is unlikely to work.
>
> 1) It turns basically everything into a cycle.
>

Why a cycle?

2) __qualname__ is determined strictly from syntax, whereas __parent__ could
> not be. For example, what happens if I take a method from one class and set
> it on another? __parent__ would not be well-defined.
>

I'm suggesting that parent be determined purely from declaration.  If you
copy something, neither qualname nor parent would change unless you change
them.


> Regards,
> Benjamin
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/94fTkAkjhCo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141005/6de34cc6/attachment.html>


More information about the Python-ideas mailing list