On Wed, Oct 20, 2010 at 1:33 PM, Daniel Wagner
brocki2...@googlemail.com wrote:
Any more efficient ways or suggestions are still welcome!
In article mailman.58.1287547882.2218.python-l...@python.org
James Mills prolo...@shortcircuit.net.au wrote:
Did you not see Paul Rubin's solution:
[x+(y,)
Daniel Wagner wrote:
Hello Everyone,
I'm new in this group and I hope it is ok to directly ask a question.
My short question: I'm searching for a nice way to merge a list of
tuples with another tuple or list. Short example:
a = [(1,2,3), (4,5,6)]
b = (7,8)
After the merging I would
Many thanks for all these suggestions! here is a short proof that you
guys are absolutely right and my solution is pretty inefficient.
One of your ways:
$ python /[long_path]/timeit.py 'a=[(1,2,3),(4,5,6)];b=(7,8);[x+(y,)
for x,y in zip(a,b)]'
100 loops, best of 3: 1.44 usec per loop
And my
On Wed, 20 Oct 2010 14:32:53 -0700, Daniel Wagner wrote:
I really appreciate your solutions but they bring me to a new question:
Why is my solution so inefficient? The same operation without the
list/tuple conversion
$ python /[long_path]/timeit.py 'a=[[1,2,3], [4,5,6]];b=[7,8];map(lambda
[b.pop(0)]
This has to lookup the global b, resize it, create a new list,
concatenate it with the list x (which creates a new list, not an in-place
concatenation) and return that. The amount of work is non-trivial, and I
don't think that 3us is unreasonable.
I forgot to take account
Hello Everyone,
I'm new in this group and I hope it is ok to directly ask a question.
My short question: I'm searching for a nice way to merge a list of
tuples with another tuple or list. Short example:
a = [(1,2,3), (4,5,6)]
b = (7,8)
After the merging I would like to have an output like
On Wed, Oct 20, 2010 at 10:16 AM, Daniel Wagner
brocki2...@googlemail.com wrote:
My short question: I'm searching for a nice way to merge a list of
tuples with another tuple or list. Short example:
a = [(1,2,3), (4,5,6)]
b = (7,8)
After the merging I would like to have an output like
On Oct 19, 8:35 pm, James Mills prolo...@shortcircuit.net.au wrote:
On Wed, Oct 20, 2010 at 10:16 AM, Daniel Wagner
brocki2...@googlemail.com wrote:
My short question: I'm searching for a nice way to merge a list of
tuples with another tuple or list. Short example:
a = [(1,2,3), (4,5,6
Daniel Wagner brocki2...@googlemail.com writes:
My short question: I'm searching for a nice way to merge a list of
tuples with another tuple or list. Short example:
a = [(1,2,3), (4,5,6)]
b = (7,8) ...
the output should look like:
a = [(1,2,3,7), (4,5,6,8)]
That is not really
On 20/10/2010 02:26, Paul Rubin wrote:
Daniel Wagnerbrocki2...@googlemail.com writes:
My short question: I'm searching for a nice way to merge a list of
tuples with another tuple or list. Short example:
a = [(1,2,3), (4,5,6)]
b = (7,8) ...
the output should look like:
a = [(1,2,3,7), (4,5,6,8
I used the following code to add a single fixed value to both tuples.
But this is still not what I want...
a = [(1,2,3), (4,5,6)]
b = 1
a = map(tuple, map(lambda x: x + [1], map(list, a)))
a
[(1, 2, 3, 1), (4, 5, 6, 1)]
What I need is:
a = [(1,2,3), (4,5,6)]
b = (7,8)
a = CODE
a
[(1,2,3,7),
SOLVED! I just found it out
I'm searching for a nice way to merge a list of
tuples with another tuple or list. Short example:
a = [(1,2,3), (4,5,6)]
b = (7,8)
After the merging I would like to have an output like:
a = [(1,2,3,7), (4,5,6)]
The following code solves the problem
On Wed, Oct 20, 2010 at 1:33 PM, Daniel Wagner
brocki2...@googlemail.com wrote:
Any more efficient ways or suggestions are still welcome!
Did you not see Paul Rubin's solution:
[x+(y,) for x,y in zip(a,b)]
[(1, 2, 3, 7), (4, 5, 6, 8)]
I think this is much nicer and probably more efficient.
13 matches
Mail list logo