[Patches] [ python-Patches-643443 ] dict.sequpdate()

noreply@sourceforge.net noreply@sourceforge.net
Mon, 25 Nov 2002 06:26:42 -0800


Patches item #643443, was opened at 2002-11-25 11:29
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=643443&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Nobody/Anonymous (nobody)
Summary: dict.sequpdate()

Initial Comment:
Implements dict.sequpdate() as discussed on python-
dev:

def sequpdate(self, iterable, value=True):
    for k in iterable:
        self[k] = value
    return self


----------------------------------------------------------------------

>Comment By: Just van Rossum (jvr)
Date: 2002-11-25 15:26

Message:
Logged In: YES 
user_id=92689

One more thing: I'd say the default value should be None.
This makes the idiom also useful to initialize dicts which
later get filled with proper values. This doesn't take
anything away from your original use case.

----------------------------------------------------------------------

Comment By: Just van Rossum (jvr)
Date: 2002-11-25 15:09

Message:
Logged In: YES 
user_id=92689

I see no reason why d.sequpdate() should return self.
d.update() doesn't either.

Also, as I suggested on python-dev, a fromseq() constructor
(as a class method) would be nice:

  >>> dict.fromseq('End Quit Stop Abort'.split())
  {'End': True, 'Quit': True, 'Stop': True, 'Abort': True}
  >>>

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=643443&group_id=5470