пн, 6 мая 2019 г. в 19:48, Antoine Pitrou <solip...@pitrou.net>:
> On Mon, 6 May 2019 19:39:39 +0300 > Serge Matveenko <s...@matveenko.ru> wrote: > > On Mon, May 6, 2019 at 7:29 PM Guido van Rossum <gu...@python.org> > wrote: > > > > > > On Mon, May 6, 2019 at 11:14 AM Serhiy Storchaka <storch...@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. > > The main constructors for built-in types are used so pervasively that > there is no hope of actually removing such deprecated behavior. > > Especially `bytes` constructor: `bytes(int)`, it is so convenient and obvious that in the entire Python standard library it is used only in tests of its own existence: 'cpython-master/Lib/test/test_bytes.py' on line: 1023' 'cpython-master/Lib/test/test_bytes.py' on line: 1234'. Currently, `bytes` is the most ambiguous resident in Python 3. It seems that in the final version (which is very different from the initial idea), it was created to surprise: 1. Those wishing to take it as a string in Python 2 2. Those who wish to perceive it as an array of integers from 0 to 255. 3. And those who want to see `bytes` as something else... with kind regards, -gdg
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/