New submission from STINNER Victor <[email protected]>:
Each type types.CodeType constructor changes, a lot of applications break.
Python 3.8 added a new parameter which broke for example the Genshi project,
just to name one.
I propose to add a new CodeType.replace() method, similar to
datetime.datetime.replace and namedtuple._replace() for example:
$ python3
Python 3.7.3 (default, Mar 27 2019, 13:41:07)
>>> import datetime
>>> d=datetime.datetime.now()
>>> d2=d.replace(year=2010)
>>> d, d2
(datetime.datetime(2019, 5, 24, 11, 25, 3, 839966), datetime.datetime(2010, 5,
24, 11, 25, 3, 839966))
>>> import collections
>>> Point = collections.namedtuple("Point", "x y")
>>> p=Point(1, 2)
>>> p2=p._replace(y=3)
>>> p, p2
(Point(x=1, y=2), Point(x=1, y=3))
----------
components: Interpreter Core
messages: 343360
nosy: pablogsal, vstinner
priority: normal
severity: normal
status: open
title: Add CodeType.replace() method
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37032>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com