[Python-ideas] More alternate constructors for builtin type

Guido van Rossum guido at python.org
Mon May 6 12:38:06 EDT 2019


On Mon, May 6, 2019 at 11:14 AM Serhiy Storchaka <storchaka at gmail.com>
wrote:

> 06.05.19 17:49, Guido van Rossum пише:
> > 20-25 years ago this might have been a good idea. Unfortunately there's
> > so much code (including well-publicized example code) that I'm not sure
> > it's a good use of anyone's time to try and fix this.
>
> 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. :-(

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him/his **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190506/ae9d8404/attachment.html>


More information about the Python-ideas mailing list