[Python-ideas] More alternate constructors for builtin type

Serge Matveenko s at matveenko.ru
Mon May 6 12:39:39 EDT 2019


On Mon, May 6, 2019 at 7:29 PM Guido van Rossum <guido at python.org> wrote:
>
> On Mon, May 6, 2019 at 11:14 AM Serhiy Storchaka <storchaka at gmail.com> wrote:
>> I do not propose to change the current behavior. I propose to add new
>> named constructors. In most cases default constructors can be used, but
>> in cases when we use type check or different tricks to limit the type of
>> the argument, we could use named constructors.
>>
>> Current named constructors:
>>
>> * dict.fromkeys()
>> * int.from_bytes()
>> * float.fromhex()
>> * bytes.fromhex()
>> * bytearray.fromhex()
>
>
> Understood. My point is that we won't be able to remove the original behavior, so we'd end up with two ways to do it. :-(

With all respect, I disagree. There are ways to evolve Python such as
deprecation policies which proven to be effective. There are ways to
monitor current features adoption on PyPI to see whether it is safe to
remove deprecated things.

I'd understand if some feature is not accepted to Python if it is
kinda bad. What I refuse to accept as a user is that behavior
considered bad and ready to be improved is preserved through time just
because it is there already.

Please, get me right. I totally agree that this will bring up two ways
of performing the same thing but we can deprecate one of them, keep
track of the new way adoption and finally get Python to a better state
if it is really desired.


More information about the Python-ideas mailing list