Author vstinner
Recipients pablogsal, vstinner
Date 2019-05-24.09:25:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558689955.85.0.932624363868.issue37032@roundup.psfhosted.org>
In-reply-to
Content
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))
History
Date User Action Args
2019-05-24 09:25:55vstinnersetrecipients: + vstinner, pablogsal
2019-05-24 09:25:55vstinnersetmessageid: <1558689955.85.0.932624363868.issue37032@roundup.psfhosted.org>
2019-05-24 09:25:55vstinnerlinkissue37032 messages
2019-05-24 09:25:55vstinnercreate