On Jul 1, 8:26 pm, Tobiah <[EMAIL PROTECTED]> wrote:
> master,slave1,slave2=zip(*x)
>
> What does the asterisk do here?
>
> Thanks
> ** Posted fromhttp://www.teranews.com**
Hi Tobiah,
I blogged extensively on this zip(*x) trick here:
http://paddy3118.blogspot.com/2007/02/unzip-un-needed-in-
Tobiah <[EMAIL PROTECTED]> wrote:
> master,slave1,slave2=zip(*x)
>
> What does the asterisk do here?
>
> Thanks
> ** Posted from http://www.teranews.com **
Instead of passing a single argument x to zip() you can think of it
unpacking the list x and passing len(x) arguments to zip.
So if
master,slave1,slave2=zip(*x)
What does the asterisk do here?
Thanks
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list
> >>> x=zip(master,slave1,slave2)
> >>> x.sort()
> >>> master,slave1,slave2=zip(*x)
> --Mark
So nice is Python.
Leo
--
http://mail.python.org/mailman/listinfo/python-list
"leodp" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Or provide a better explanation and an example. Do you mean something
like
this?
Hi Peter,
a small example:
master=[1,4,3,2]
slave1=['d','c','b','a']
slave2=[1,2,3,4]
master.sort() # this is ok, but does not return info
> >>> master_index.sort(key=master.__getitem__)
that was it!
Thanks Peter, leodp
--
http://mail.python.org/mailman/listinfo/python-list
leodp wrote:
>
>> Or provide a better explanation and an example. Do you mean something
>> like this?
>>
>
> Hi Peter,
> a small example:
>
> master=[1,4,3,2]
> slave1=['d','c','b','a']
> slave2=[1,2,3,4]
>
> master.sort() # this is ok, but does not return infos on how the list
> was sorted
>
> Or provide a better explanation and an example. Do you mean something like
> this?
>
Hi Peter,
a small example:
master=[1,4,3,2]
slave1=['d','c','b','a']
slave2=[1,2,3,4]
master.sort() # this is ok, but does not return infos on how the list
was sorted
slave1.sort(key=_maybe_something_here_ref
leodp wrote:
> I cannot find anything on this:
> I have a few lists, and would like to sort one of them (sorting-master
> list).
> Then I would like to sort all other lists according to how the first
> one was sorted (sorting-slave lists).
>
> Is there a standard way to do that?
> From what I kno
Hi all,
I cannot find anything on this:
I have a few lists, and would like to sort one of them (sorting-master
list).
Then I would like to sort all other lists according to how the first
one was sorted (sorting-slave lists).
Is there a standard way to do that?
>From what I know sort() and sorted(
10 matches
Mail list logo