[Python-Dev] What if replacing items in a dictionary returns the new dictionary? (original) (raw)
Roy Hyunjin Han starsareblueandfaraway at gmail.com
Fri Apr 29 16:27:46 CEST 2011
- Previous message: [Python-Dev] Identity implies equality
- Next message: [Python-Dev] What if replacing items in a dictionary returns the new dictionary?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
It would be convenient if replacing items in a dictionary returns the new dictionary, in a manner analogous to str.replace(). What do you think? :: # Current behavior x = {'key1': 1} x.update(key1=3) == None x == {'key1': 3} # Original variable has changed
# Possible behavior
x = {'key1': 1}
x.replace(key1=3) == {'key1': 3}
x == {'key1': 1} # Original variable is unchanged- Previous message: [Python-Dev] Identity implies equality
- Next message: [Python-Dev] What if replacing items in a dictionary returns the new dictionary?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]