On Fri, May 13, 2016 at 9:00 PM, Steven D'Aprano <st...@pearwood.info> wrote:
> Cons:
> (3) Polymorphic code that truly doesn't care whether it gets bytes or
> str will have a slightly less convenient way of getting it, namely by
> calling __fspath__() itself, instead of os.fspath().

I don't like this; it goes against the general principle that dunders
are for defining, not calling. Generally, a given dunder method has
approximately one call site, eg __reduce__ in pickle.py, and everyone
else defines it. (You might call super's dunder in the definition of
your own, but that's still defining it, not calling it.) Having an
official statement that it's appropriate to call a dunder confuses
this. So this isn't a "slightly less convenient way", it's a bad way
(IMO), and this is a very strong con.

ChrisA
_______________________________________________
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