(original) (raw)
��� x = a[[y]]
would be approximately equivalent to
�� �x = [a[i] for i in y]
and
�� �a\[\[x\]\] = ywould be approximately equivalent to
�� �for (i,j) in zip(x,y): a\[i\] = j
except that zip throws away excess values in the longer sequence and I think \[\[..\]\] would throw an exception.
--- Bruce
http://www.vroospeak.com
http://google-gruyere.appspot.com
On Tue, Jul 20, 2010 at 3:51 PM, Mathias Panzenb�ck <grosser.meister.morti@gmx.net> wrote:
I'm not sure what this is about but do you mean something like this?
>>> l=[1,2,3,4]
>>> l[1:2] = ['a','b']
>>> l
[1, 'a', 'b', 3, 4]
On 07/20/2010 09:17 PM, Bruce Leban wrote:
\[changing the subject; was: 'where' statement in Python?\]
I think this is an interesting idea (whether worth adding is a different question). I think it would
be confusing that
� �a\[x\] = (y,z)
does something entirely different when x is 1 or (1,2). If python \*were\* to add something like this,
I think perhaps a different syntax should be considered:
a\[\[x\]\] = y
y = a\[\[x\]\]
which call \_\_setitems\_\_ and \_\_getitems\_\_ respectively. This makes it clear that something different
is going on and eliminates the ambiguity for dicts.
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas