2011/4/29 Roy Hyunjin Han starsareblueandfara...@gmail.com:
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
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
2011/4/29 R. David Murray rdmur...@bitdance.com:
2011/4/29 Roy Hyunjin Han starsareblueandfara...@gmail.com:
It would be convenient if replacing items in a dictionary returns the
new dictionary, in a manner analogous to str.replace()
This belongs on python-ideas, but the short answer
You can implement this in your own subclass of dict, no?
Yes, I just thought it would be convenient to have in the language
itself, but the responses to my post seem to indicate that [not
returning the updated object] is an intended language feature for
mutable types like dict or list.
class
On Fri, Dec 11, 2009 at 7:59 PM, Nick Coghlan ncogh...@gmail.com wrote:
It follows the standard left-to-right evaluation order within an expression:
subexpr1(subexpr2)
(i.e. a function call always determines which function is going to be
called before determining any arguments to be passed)
While debugging a network algorithm in Python 2.6.2, I encountered
some strange behavior and was wondering whether it has to do with some
sort of code optimization that Python does behind the scenes.
After initialization: defaultdict(type 'set', {1: set([1])})
Popping and updating
On Fri, Dec 11, 2009 at 2:43 PM, MRAB pyt...@mrabarnett.plus.com wrote:
John Arbash Meinel wrote:
Roy Hyunjin Han wrote:
While debugging a network algorithm in Python 2.6.2, I encountered
some strange behavior and was wondering whether it has to do with some
sort of code optimization
I know that Python has iterator methods called sorted and reversed and
these are handy shortcuts.
Why not add a new iterator method called shuffled?
for x in shuffled(range(5)):
print x
3
1
2
0
4
Currently, a person has to do the following because random.shuffle() does
not return