Re: How to efficiently proceed addition and subtraction in python list?

2006-09-19 Thread Chiucs
try this a=[1, 2, 3] b=a[:] Daniel Mark [EMAIL PROTECTED] ??? news:[EMAIL PROTECTED] ???... Hello all: I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] What should I do? Thank you -Daniel --

Re: How to efficiently proceed addition and subtraction in python list?

2006-09-19 Thread Paul Rubin
Daniel Mark [EMAIL PROTECTED] writes: I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] What should I do? BBB = [x-1 for x in AAA] -- http://mail.python.org/mailman/listinfo/python-list

Re: How to efficiently proceed addition and subtraction in python list?

2006-09-19 Thread Ant
Tim Chase wrote: I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] What should I do? Sounds like a list comprehension to me: Also the built in function 'map' would work: a = [1,2,3] b = map(lambda x: x-1, a) b [0, 1, 2] List

Re: How to efficiently proceed addition and subtraction in python list?

2006-09-19 Thread Steve Holden
Ant wrote: Tim Chase wrote: I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] What should I do? Sounds like a list comprehension to me: Also the built in function 'map' would work: a = [1,2,3] b = map(lambda x: x-1, a) b [0, 1, 2]

Re: How to efficiently proceed addition and subtraction in python list?

2006-09-19 Thread Simon Brunning
On 18 Sep 2006 15:43:31 -0700, Daniel Mark [EMAIL PROTECTED] wrote: Hello all: I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] You've had some excellent suggestions as to how to go about this assuming that by efficient you mean in terms of CPU.

How to efficiently proceed addition and subtraction in python list?

2006-09-18 Thread Daniel Mark
Hello all: I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] What should I do? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: How to efficiently proceed addition and subtraction in python list?

2006-09-18 Thread Tim Chase
I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] What should I do? Sounds like a list comprehension to me: a = [1,2,3] a_prime = [x-1 for x in a] a_prime [0, 1, 2] -tkc -- http://mail.python.org/mailman/listinfo/python-list