[Python-ideas] More alternate constructors for builtin type
Serhiy Storchaka
storchaka at gmail.com
Mon May 6 12:13:05 EDT 2019
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()
More information about the Python-ideas
mailing list