Simon Dahlbacka wrote:
> Oooh.. you make my eyes bleed. IMO that proposal is butt ugly (and
> looks like the C++.NET perversions.)
I haven't had the displeasure of using C++.NET fortunately.
point = [5,(10,20,5)]
size,t = point
x,y,z = t
size,x,y,z = point[0], point[1][0], poi
Raymond Hettinger wrote:
> [Ron Adam]
>
>>Currently we can implicitly unpack a tuple or list by using an
>>assignment. How is that any different than passing arguments to a
>>function? Does it use a different mechanism?
>
>
> It is the same mechanism, so it is also only appropriate for low
> v
On Sun, 17 Jul 2005 19:38:29 -0700, Raymond Hettinger wrote:
> Executive summary: Python's for-loops are both elegant and fast. It
> is a mistake to habitually avoid them.
And frequently much more readable and maintainable than the alternatives.
I cringe when I see well-meaning people trying t
[Ron Adam]
> Currently we can implicitly unpack a tuple or list by using an
> assignment. How is that any different than passing arguments to a
> function? Does it use a different mechanism?
It is the same mechanism, so it is also only appropriate for low
volumes of data:
a, b, c = *args
Oooh.. you make my eyes bleed. IMO that proposal is butt ugly (and
looks like the C++.NET perversions.)
--
http://mail.python.org/mailman/listinfo/python-list
Raymond Hettinger wrote:
>>Variant of Paul's example:
>>
>>a = ((1,2), (3, 4), (5, 6), (7, 8), (9, 10))
>>zip(*a)
>>
>>or
>>
>>[list(t) for t in zip(*a)] if you need lists instead of tuples.
>
>
>
> [Peter Hansen]
>
>>(I believe this is something Guido considers an "abuse of *args", but I
>>jus
[Richard]
> I know I can use a 'for' loop and create two new lists
> using 'newList1.append(x)', etc. Is there an efficient way
> to create these two new lists without using a slow for loop?
If trying to optimize before writing and timing code, then at least
validate your assumptions. In Python,
> Variant of Paul's example:
>
> a = ((1,2), (3, 4), (5, 6), (7, 8), (9, 10))
> zip(*a)
>
> or
>
> [list(t) for t in zip(*a)] if you need lists instead of tuples.
[Peter Hansen]
> (I believe this is something Guido considers an "abuse of *args", but I
> just consider it an elegant use of zip() co
Richard wrote:
> On Wed, 13 Jul 2005 20:53:58 -0400, Peter Hansen wrote:
>>a = ((1,2), (3, 4), (5, 6), (7, 8), (9, 10))
>>zip(*a)
> This seems to work. Thanks.
>
> Where do I find documentation on "*args"?
In the language reference: http://docs.python.org/ref/calls.html#calls
-Peter
--
http:/
On Wed, 13 Jul 2005 20:53:58 -0400, Peter Hansen wrote:
> a = ((1,2), (3, 4), (5, 6), (7, 8), (9, 10))
> zip(*a)
>
This seems to work. Thanks.
Where do I find documentation on "*args"?
--
http://mail.python.org/mailman/listinfo/python-list
Joseph Garvin wrote:
> Peter Hansen wrote:
>
>> (I believe this is something Guido considers an "abuse of *args", but
>> I just consider it an elegant use of zip() considering how the
>> language defines *args. YMMV]
>>
>> -Peter
>>
>>
> An abuse?! That's one of the most useful things to do w
Peter Hansen wrote:
>(I believe this is something Guido considers an "abuse of *args", but I
>just consider it an elegant use of zip() considering how the language
>defines *args. YMMV]
>
>-Peter
>
>
An abuse?! That's one of the most useful things to do with it. It's
transpose.
--
http://ma
Richard wrote:
> I have a large list of two element tuples. I want two separate
> lists: One list with the first element of every tuple, and the
> second list with the second element of every tuple.
Variant of Paul's example:
a = ((1,2), (3, 4), (5, 6), (7, 8), (9, 10))
zip(*a)
or
[list(t) for
Richard <[EMAIL PROTECTED]> writes:
> I have a large list of two element tuples. I want two separate
> lists: One list with the first element of every tuple, and the
> second list with the second element of every tuple.
>
> I know I can use a 'for' loop and create two new lists
> using 'newList1.a
if t is your data, you can use:
l1, l2 = zip(*t)
Cyril
On 7/14/05, Richard <[EMAIL PROTECTED]> wrote:
I have a large list of two element tuples. I want two separatelists: One list with the first element of every tuple, and thesecond list with the second element of every tuple.Each tuple contains
15 matches
Mail list logo