

On Mon, Mar 31, 2008, Mathias Panzenb?ck wrote:
Horrible idea. ;-) -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan

2008/3/31, Mathias Panzenböck <grosser.meister.morti@gmx.net>:
Bad idea. It uncovers a lot of details for your brain to take care when doing that, for example:
I would consider something like the following: bar, spam = d.multiple("foo", "egg") with the semantics of: bar, spam = [d[k] for k in ("foo", "egg")] Regards, -- . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/

"Facundo Batista" <facundobatista@gmail.com> wrote in message news:e04bdf310804010613h56d11f19u5253b05602a14778@mail.gmail.com... -1 because the need is way to rare for new syntax support and because | bar, spam = [d[k] for k in ("foo", "egg")] already does what is wanted in easily understood code. tjtr

Facundo Batista schrieb:
We also have bar, spam = itemgetter("foo", "egg")(d) if some functional form is preferred. Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.

Maybe just extend the functionality of the __getitem__ and __setitem__ methods of dicts?
def __setitem__(self,key,value): if type(key) in (tuple, list): for k, v in zip(key,value): dict.__setitem__(self,k,v) else: dict.__setitem__(self,key,value)
Well, this would break current behaviour, so actually no. Not good. But maybe that way (no conflict because lists are unhashable):
def __setitem__(self,key,value): if isinstance(key,list): for k, v in zip(key,value): dict.__setitem__(self,k,v) else: dict.__setitem__(self,key,value)
The [[ ]] looks almost like a spacial syntax. Good or bad? -panzi

On Mon, Mar 31, 2008, Mathias Panzenb?ck wrote:
Horrible idea. ;-) -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan

2008/3/31, Mathias Panzenböck <grosser.meister.morti@gmx.net>:
Bad idea. It uncovers a lot of details for your brain to take care when doing that, for example:
I would consider something like the following: bar, spam = d.multiple("foo", "egg") with the semantics of: bar, spam = [d[k] for k in ("foo", "egg")] Regards, -- . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/

"Facundo Batista" <facundobatista@gmail.com> wrote in message news:e04bdf310804010613h56d11f19u5253b05602a14778@mail.gmail.com... -1 because the need is way to rare for new syntax support and because | bar, spam = [d[k] for k in ("foo", "egg")] already does what is wanted in easily understood code. tjtr

Facundo Batista schrieb:
We also have bar, spam = itemgetter("foo", "egg")(d) if some functional form is preferred. Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.

Maybe just extend the functionality of the __getitem__ and __setitem__ methods of dicts?
def __setitem__(self,key,value): if type(key) in (tuple, list): for k, v in zip(key,value): dict.__setitem__(self,k,v) else: dict.__setitem__(self,key,value)
Well, this would break current behaviour, so actually no. Not good. But maybe that way (no conflict because lists are unhashable):
def __setitem__(self,key,value): if isinstance(key,list): for k, v in zip(key,value): dict.__setitem__(self,k,v) else: dict.__setitem__(self,key,value)
The [[ ]] looks almost like a spacial syntax. Good or bad? -panzi
participants (7)
-
Aahz
-
Christian Heimes
-
Facundo Batista
-
Georg Brandl
-
Giampaolo Rodola'
-
Mathias Panzenböck
-
Terry Reedy