On Fri, Sep 18, 2020 at 1:05 PM Christopher Barker <python...@gmail.com> wrote:
> I see the issue here, but isn't that inherent in duck typing? It's not 
> specific to overloading. In fact the current implementation of json.load() 
> simply calls the .read() in the object passed in. If it does not have a read 
> method, you get an AttributeError. IF someone where to pass in a string 
> subclass with a read method, and that method returned the right thing, it 
> would "just work". Here's an example:
>

Yes - it would indeed just work, and that's because the function
*name* specifies whether it's going to read from a file object or open
a path name. There's no ambiguity; if you call load() on something
that's both a path and a file, it'll work, and if you call loadf() on
something that's both a path and a file, it'll also just work. But if
you try to make those into one and the same function, how's it going
to pick from the two options?

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/P7CH4PCARRA3R2YYRCZ7NDVASMMBCVLB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to