On 05/13/2016 08:43 AM, Brett Cannon wrote:

a minor technical query:

        try:
            return path.__fspath__()

Would I be right in saying that in practice this will actually end up
being type(path).__fspath__() to match the behaviour of all(?) other
dunder methods?

I wasn't planning on it because for most types the accessing of the
method directly off of the type for magic methods is because of some
special struct field at the C level that we're pulling from. Since we're
not planning to have an equivalent struct field I don't see any need to
do the extra work of avoiding the instance participating in method
lookup. Obviously if people disagree for some reason then please let me
know (maybe for perf by avoiding the overhead of checking for the method
on the instance?).

I would say use `type(x).__fspath__`. I'm not aware of any other __dunder__ method that doesn't access the attribute from the type instead of the instance, and I see no point in making this one different.

I know there's a line in the Zen about foolish conistencies, but I suspect there's a corollary about foolish inconsistencies. ;)

--
~Ethan~

_______________________________________________
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