On Fri, 11 Sep 2020 at 19:50, David Mertz <me...@gnosis.cx> wrote:

> I like the idea of having these functions, but I don't like overloading
> the argument to a function with "filename or file-like object" as is common
> in libraries like Pandas.  I think there are a few places the standard
> library does it, but the separation seems better to me.
>
> I don't LOVE the names dumpf() and loadf(), but I don't have an obviously
> better choice.  I guess probably I'd want fromfile() and tofile() as more
> "modern" names.
>

While separating the methods to avoid method overloading feels much cleaner
(and I also think of it that way), w have to look at the
other side of it:
If .load and .dump are super-charged, people coding with these methods in
mind have _one_ less_  thing to worry about:
if the method accepts a path or an open file becomes irrelevant. On th othr
hand, with two extra methods,
anyone coding the samething have one _extra_ thing to worry about, even
more things than they have today!
Nowadays, one learn that 'ok, so load takes an open file", and that's it.
With two new methods it becomes
"ok, was it dump or dumpf which took an openfile? Or was it the other way
around?" - and that is bad.

Parameter overloading has been around from O.O. inception, it is used in
other parts of Python, and
permissive signatures are part of what made Python so atractive along the
years.

So, this is "the other side".


>
> On Fri, Sep 11, 2020 at 12:17 PM Christopher Barker <python...@gmail.com>
> wrote:
>
>> I"m pretty sure this came up recently, and was pretty much rejected.
>>
>> Another option would be to have json.dump take a file-like-object or a
>> path-like object -- there's plenty of code out there that does that.
>>
>> hmm.. maybe that was the version that was rejected.
>>
>> But I like the idea either way. it always seemed cumbersome to me to
>> write the whole context manager in these kinds of cases.
>>
>> -CHB
>>
>>
>>
>>
>>
>> On Fri, Sep 11, 2020 at 2:05 PM The Nomadic Coder <
>> atemysemico...@gmail.com> wrote:
>>
>>> Personally prefer it to be in the json module as it just feels more
>>> logical. But that's just a personal choice.
>>>
>>> I didn't mention about dumpf as I see a previous thread that became
>>> quite controversial (seems like dumps was a more common usage at that time).
>>>
>>> Something I forgot to mention : A (non-exact)search for this construct
>>> in github (https://github.com/search?q=with+open+%3A+json.load&type=Code)
>>> gives 20million+ results. Seems like it's a popular set of statements that
>>> people use ...
>>>
>>> ----
>>> The Nomadic Coder
>>> _______________________________________________
>>> 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/R4CZ2IGLXR5NYNQDDFZZE5YB3RHD3RP6/
>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>>
>>
>>
>> --
>> Christopher Barker, PhD
>>
>> Python Language Consulting
>>   - Teaching
>>   - Scientific Software Development
>>   - Desktop GUI and Web Development
>>   - wxPython, numpy, scipy, Cython
>> _______________________________________________
>> 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/4XVZAXRXQKZKTJJAH4WHXFVQGA57YFAV/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>
>
> --
> The dead increasingly dominate and strangle both the living and the
> not-yet born.  Vampiric capital and undead corporate persons abuse
> the lives and control the thoughts of homo faber. Ideas, once born,
> become abortifacients against new conceptions.
> _______________________________________________
> 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/WOTLFRSGGRGVIYEIOCTGQJAWA2KK5PPJ/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
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/EQGT5IESXX265YBI5YA4IYVL5A7ARSRH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to