Re: [Python-Dev] What if replacing items in a dictionary returns the new dictionary?

2011-05-05 Thread Roy Hyunjin Han
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

[Python-Dev] What if replacing items in a dictionary returns the new dictionary?

2011-04-29 Thread Roy Hyunjin Han
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

Re: [Python-Dev] What if replacing items in a dictionary returns the new dictionary?

2011-04-29 Thread Roy Hyunjin Han
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

Re: [Python-Dev] What if replacing items in a dictionary returns the new dictionary?

2011-04-29 Thread Roy Hyunjin Han
  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

Re: [Python-Dev] Splitting something into two steps produces different behavior from doing it in one fell swoop in Python 2.6.2

2009-12-14 Thread Roy Hyunjin Han
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)

[Python-Dev] Splitting something into two steps produces different behavior from doing it in one fell swoop in Python 2.6.2

2009-12-11 Thread Roy Hyunjin Han
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

Re: [Python-Dev] Splitting something into two steps produces different behavior from doing it in one fell swoop in Python 2.6.2

2009-12-11 Thread Roy Hyunjin Han
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

[Python-Dev] About adding a new iterator method called shuffled

2009-03-24 Thread Roy Hyunjin Han
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