[issue43580] A Question about List Slice

2021-03-21 Thread Mark Dickinson
Change by Mark Dickinson : -- components: -Regular Expressions ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue43580] A Question about List Slice

2021-03-21 Thread Mark Dickinson
Mark Dickinson added the comment: It's behaving as designed and documented; see the docs here: https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range (and particularly note 3). In your first example, the first `-1` in `x[1:-1:-1]` is interpreted relative to the end

[issue43580] A Question about List Slice

2021-03-21 Thread LittleGuy
2 : -1] print(a) # the answer will be: [4, 3] # so, there may be some problems. -- components: Regular Expressions messages: 389220 nosy: YangS007, ezio.melotti, mrabarnett priority: normal severity: normal status: open title: A Question about List Slice type: behavior versions: Pyth

[issue34531] doc Move comment about list sorting behavour outside impl-detail directive

2018-08-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: The sentence should be left as-is. It is there to make the following two sentences more intelligible. The docs otherwise make no promises about other implementations and this is as it should be. -- nosy: +rhettinger resolution: -> rejected

[issue34531] doc Move comment about list sorting behavour outside impl-detail directive

2018-08-28 Thread Andrés Delfino
Change by Andrés Delfino : -- keywords: +patch pull_requests: +8450 stage: -> patch review ___ Python tracker ___ ___

[issue34531] doc Move comment about list sorting behavour outside impl-detail directive

2018-08-28 Thread Andrés Delfino
-detail directive. -- assignee: docs@python components: Documentation messages: 324259 nosy: adelfino, docs@python priority: normal severity: normal status: open title: doc Move comment about list sorting behavour outside impl-detail directive type: enhancement versions: Python 2.7, Python

Re: a question about list as an element in a tuple

2014-02-19 Thread Marko Rauhamaa
John O'Hagan resea...@johnohagan.com: The weirdest part for me is this: t = ([],) l = t[0] l is t[0] True l += [1] t[0] += [1] Traceback (most recent call last): File stdin, line 1, in module TypeError: 'tuple' object does not support item assignment Whether there is an error or

Re: a question about list as an element in a tuple

2014-02-19 Thread Marko Rauhamaa
Marko Rauhamaa ma...@pacujo.net: operator.add(x, y) [...] leaves x and y intact and must return a new object. Well, if the addition doesn't modify x, the method can of course return x. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: a question about list as an element in a tuple

2014-02-18 Thread John O'Hagan
On Mon, 16 Dec 2013 11:30:13 +0800 liuerfire Wang liuerf...@gmail.com wrote: Just like below: In [1]: a = ([], []) In [2]: a[0].append(1) In [3]: a Out[3]: ([1], []) In [4]: a[0] += [1] --- TypeError

a question about list as an element in a tuple

2013-12-15 Thread liuerfire Wang
Just like below: In [1]: a = ([], []) In [2]: a[0].append(1) In [3]: a Out[3]: ([1], []) In [4]: a[0] += [1] --- TypeError Traceback (most recent call last) ipython-input-4-ea29ca190a4d in

Re: a question about list as an element in a tuple

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 2:30 PM, liuerfire Wang liuerf...@gmail.com wrote: TypeError: 'tuple' object does not support item assignment In [5]: a Out[5]: ([1, 1], []) no problem, there is an exception. But a is still changed. is this a bug, or could anyone explain it? It's not a bug, but

Re: a question about list as an element in a tuple

2013-12-15 Thread rusi
On Monday, December 16, 2013 9:27:11 AM UTC+5:30, Chris Angelico wrote: On Mon, Dec 16, 2013 at 2:30 PM, liuerfire Wang wrote: TypeError: 'tuple' object does not support item assignment In [5]: a Out[5]: ([1, 1], []) no problem, there is an exception. But a is still changed. is this a

About list Pyclutter

2011-04-02 Thread craf
Hi. Does anyone know if pyclutter has a mailing list? Regards. Cristian Abarzúa -- http://mail.python.org/mailman/listinfo/python-list

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Alban Nona
Hello, So I figure out this night how to create automatically varibales via vars(), the script seems to work, exept that where it should give me a list like : [ELM004_DIF,ELM004_SPC,ELM004_RFL,ELM004_SSS, ELM004_REFR, ELM004_ALB, etc...] it gave me just one entry in my list, and the last one

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 00:47, Alban Nona python.k...@gmail.com wrote: Hello, So I figure out this night how to create automatically varibales via vars(), the script seems to work, exept that where it should give me a list like : [ELM004_DIF,ELM004_SPC,ELM004_RFL,ELM004_SSS, ELM004_REFR,

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Alban Nona
Hello, seems to have the same error with python. In fact I was coding within nuke, a 2d compositing software (not the best) unfortunately, I dont see how I can use dictionnary to do what I would like to do. 2010/9/1 Xavier Ho cont...@xavierho.com On 2 September 2010 00:47, Alban Nona

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 01:11, Alban Nona python.k...@gmail.com wrote: Hello, seems to have the same error with python. In fact I was coding within nuke, a 2d compositing software (not the best) unfortunately, I dont see how I can use dictionnary to do what I would like to do. Hello Alban,

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Alban Nona
Hello Xavier, Thank you :) Well what Iam trying to generate is that kind of result: listn1=['ELM001_DIF', 'ELM001_SPC', 'ELM001_RFL', 'ELM001_SSS', 'ELM001_REFR', 'ELM001_ALB', 'ELM001_AMB', 'ELM001_NRM', 'ELM001_MVE', 'ELM001_DPF', 'ELM001_SDW', 'ELM001_MAT', 'ELM001_WPP'] listn2 =

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 02:49, Alban Nona python.k...@gmail.com wrote: Well what Iam trying to generate is that kind of result: listn1=['ELM001_DIF', 'ELM001_SPC', 'ELM001_RFL', 'ELM001_SSS', 'ELM001_REFR', 'ELM001_ALB', 'ELM001_AMB', 'ELM001_NRM', 'ELM001_MVE', 'ELM001_DPF', 'ELM001_SDW',

Re: Dumb Stupid Question About List and String

2010-09-01 Thread MRAB
On 01/09/2010 17:49, Alban Nona wrote: Hello Xavier, Thank you :) Well what Iam trying to generate is that kind of result: listn1=['ELM001_DIF', 'ELM001_SPC', 'ELM001_RFL', 'ELM001_SSS', 'ELM001_REFR', 'ELM001_ALB', 'ELM001_AMB', 'ELM001_NRM', 'ELM001_MVE', 'ELM001_DPF', 'ELM001_SDW',

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
2010/9/2 Alban Nona python.k...@gmail.com Hello Xavier, working great ! thank you very much ! :p Do you know by any chance if dictionnary can be sorted asthis: Look at the sorted() global function in the Python API. ;] Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Dumb Stupid Question About List and String

2010-08-31 Thread Alban Nona
Hi all, Im stuck on this problem: I have a function which return me a list of string (basically the result looks like: [FN067_098_MEN, FN067_098_JIN, FN067_098_BG] In other hand, I have another list full of that kind of entries:

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Alban Nona
Ok, here a solution: myFirstList = [FN067_098_MEN, FN067_098_JIN, FN067_098_BG] mySecondList = [FN067_098_MEN_Hair_PUZ_v001.0001.exr,FN067_098_JIN_Hair_SPC_v001.0001.exr,FN067_098_MEN_Jin_MVE_v001.0001.exr,FR043_010_GEN_NRM_v001.0001.exr] for n in myFirstList: var = str(n) for n in

Re: Dumb Stupid Question About List and String

2010-08-31 Thread MRAB
On 31/08/2010 19:57, Alban Nona wrote: Hi all, Im stuck on this problem: I have a function which return me a list of string (basically the result looks like: [FN067_098_MEN, FN067_098_JIN, FN067_098_BG] In other hand, I have another list full of that kind of entries:

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Chris Rebert
On Tue, Aug 31, 2010 at 12:20 PM, Alban Nona python.k...@gmail.com wrote: Ok, here a solution: snip for n in myFirstList: var = str(n) n is already a string, so the previous line doesn't do anything useful. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Dumb Stupid Question About List and String

2010-08-31 Thread MRAB
On 31/08/2010 20:20, Alban Nona wrote: Ok, here a solution: myFirstList = [FN067_098_MEN, FN067_098_JIN, FN067_098_BG] mySecondList = [FN067_098_MEN_Hair_PUZ_v001.0001.exr,FN067_098_JIN_Hair_SPC_v001.0001.exr,FN067_098_MEN_Jin_MVE_v001.0001.exr,FR043_010_GEN_NRM_v001.0001.exr] for n in

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Shashwat Anand
On Wed, Sep 1, 2010 at 12:27 AM, Alban Nona python.k...@gmail.com wrote: Hi all, Im stuck on this problem: I have a function which return me a list of string (basically the result looks like: [FN067_098_MEN, FN067_098_JIN, FN067_098_BG] In other hand, I have another list full of that kind

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Alban Nona
Well, I have a lot to learn :) Thank you very much both of you ! it seems to work now :p 2010/8/31 MRAB pyt...@mrabarnett.plus.com On 31/08/2010 20:20, Alban Nona wrote: Ok, here a solution: myFirstList = [FN067_098_MEN, FN067_098_JIN, FN067_098_BG] mySecondList =

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Alban Nona
Just Another Question on this one, Im trying to create that kind of thing in code now: #GENERE ET INCREMENT LE NOM DES ELEMENTS val = 0 list = [0, 1, 2, 3] listEl = [] for n in list: val = val + 1 next = 00 +str(val) elem = ELM+next listEl.append(elem) #INCREMENT LE

Re: Dumb Stupid Question About List and String

2010-08-31 Thread MRAB
On 31/08/2010 22:57, Alban Nona wrote: Just Another Question on this one, Im trying to create that kind of thing in code now: #GENERE ET INCREMENT LE NOM DES ELEMENTS val = 0 list = [0, 1, 2, 3] listEl = [] for n in list: val = val + 1 next = 00 +str(val) elem =

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Xavier Ho
On 1 September 2010 07:57, Alban Nona python.k...@gmail.com wrote: listPass = [DIF,SPC, RFL, SSS, REFR, ALB, AMB, NRM, MVE, DPF, SDW, MAT, WPP] Out of curiosity, could you briefly mention what SDW and WPP passes are? I've worked out the rest, and these two are riddling my brain. (On topic:

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Alban Nona
@MRAB, thank you, but what if there are like 40 entries like 'Elem00x' ? is there a way to do it automaticaly ? @Xavier: ShaDoW, WorldPositionPoint (which is the same thing as WordPointCloud passe) :) Anyway, thank you ! 2010/8/31 Xavier Ho cont...@xavierho.com On 1 September 2010 07:57,

Re: Dumb Stupid Question About List and String

2010-08-31 Thread MRAB
On 01/09/2010 03:00, Alban Nona wrote: @MRAB, thank you, but what if there are like 40 entries like 'Elem00x' ? is there a way to do it automaticaly ? If you can do it for 'Elem001', I'm sure you could write some code to produce a list of 'Elem001', 'Elem002', etc, and check whether any are

Fwd: Dumb Stupid Question About List and String

2010-08-31 Thread Alban Nona
In fact, the First list (wich contain Elm001, Elm002, Elm003) will be generated automatically from files that I have in a directory, that's why I cant write the same code for Elm002, 003, etc... Because Ill not know how many Elm there will be. 2010/8/31 MRAB pyt...@mrabarnett.plus.com On

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Xavier Ho
On 1 September 2010 12:00, Alban Nona python.k...@gmail.com wrote: @Xavier: ShaDoW, WorldPositionPoint (which is the same thing as WordPointCloud passe) :) Aha! That's what I was missing. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

question about list extension

2010-04-16 Thread J
Ok... I know pretty much how .extend works on a list... basically it just tacks the second list to the first list... like so: lista=[1] listb=[2,3] lista.extend(listb) print lista; [1, 2, 3] what I'm confused on is why this returns None: lista=[1] listb=[2,3] print lista.extend(listb)

Re: question about list extension

2010-04-16 Thread Bruno Desthuilliers
J a écrit : Ok... I know pretty much how .extend works on a list... basically it just tacks the second list to the first list... like so: lista=[1] listb=[2,3] lista.extend(listb) print lista; [1, 2, 3] what I'm confused on is why this returns None: So why the None? Is this because what's

Re: question about list extension

2010-04-16 Thread Lie Ryan
On 04/16/10 23:41, J wrote: Ok... I know pretty much how .extend works on a list... basically it just tacks the second list to the first list... like so: lista=[1] listb=[2,3] lista.extend(listb) print lista; [1, 2, 3] what I'm confused on is why this returns None: lista=[1]

Re: question about list extension

2010-04-16 Thread J. Cliff Dyer
On Sat, 2010-04-17 at 00:37 +1000, Lie Ryan wrote: On 04/16/10 23:41, J wrote: So, what I'm curious about, is there a list comprehension or other means to reduce that to a single line? from itertools import chain def printout(*info): print '\n'.join(map(str, chain(*info))) or

Re: question about list extension

2010-04-16 Thread Terry Reedy
On 4/16/2010 9:41 AM, J wrote: Ok... I know pretty much how .extend works on a list... basically it just tacks the second list to the first list... like so: lista=[1] listb=[2,3] lista.extend(listb) print lista; [1, 2, 3] This shows right here that lista is extended in place. If you are not

Re: question about list extension

2010-04-16 Thread J
On Fri, Apr 16, 2010 at 15:16, Terry Reedy tjre...@udel.edu wrote: On 4/16/2010 9:41 AM, J wrote: Ok... I know pretty much how .extend works on a list... basically it just tacks the second list to the first list... like so: lista=[1] listb=[2,3] lista.extend(listb) print lista; [1, 2,

Question about list comprehension/standard for disparities

2010-03-31 Thread Nathan Rice
I was just wondering, why the list/generator and standard for have disparities? It would be really nice to be able to do: for x in y if foo: ... rather than: for x in (x for x in y if foo): ... Also, from a style standpoint, I prefer to extract the loop logic into a function if it's

Re: Question about list comprehension/standard for disparities

2010-03-31 Thread Steve Holden
Nathan Rice wrote: I was just wondering, why the list/generator and standard for have disparities? It would be really nice to be able to do: for x in y if foo: ... rather than: for x in (x for x in y if foo): ... But it's not much of an issue when you can easily write

Re: Questions about list-creation

2009-12-01 Thread Manuel Graune
Thanks to all of you. You have been most helpful. Regards, Manuel Graune -- A hundred men did the rational thing. The sum of those rational choices was called panic. Neal Stephenson -- System of the world http://www.graune.org/GnuPG_pubkey.asc Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A 5828

Questions about list-creation

2009-11-30 Thread Manuel Graune
Hello, in (most) python documentation the syntax list() and [] is treated as being more or less the same thing. For example help([]) and help(list()) point to the same documentation. Since there are at least two cases where this similarity is not the case, (see below) can someone explain the

Re: Questions about list-creation

2009-11-30 Thread inhahe
On Mon, Nov 30, 2009 at 12:22 PM, Manuel Graune manuel.gra...@koeln.de wrote: Hello, in (most) python documentation the syntax list() and [] is treated as being more or less the same thing. For example help([]) and help(list()) point to the same documentation. Since there are at least two

Re: Questions about list-creation

2009-11-30 Thread Lie Ryan
afterwards: print a,a print i,i using the similar code b=list(j for j in xrange(10)) the local variable is destroyed after use: print b,b print j,j It's not so much about list() vs. [] but generator comprehension vs. list comprehension. list() takes a generator comprehension, while [listcomp

Re: Questions about list-creation

2009-11-30 Thread Mel
Manuel Graune wrote: in (most) python documentation the syntax list() and [] is treated as being more or less the same thing. For example help([]) and help(list()) point to the same documentation. Since there are at least two cases where this similarity is not the case, (see below) can

Re: Questions about list-creation

2009-11-30 Thread inhahe
i should also mention that a=[i for i in xrange(10)] and b=list(j for j in xrange(10)) isn't really just a difference of using [] vs. list() the first case is a list comprehension, the second case is a generator comprehension which is then converted to a list (the bug only applies to list

Re: Questions about list-creation

2009-11-30 Thread Stephen Hansen
On Mon, Nov 30, 2009 at 9:22 AM, Manuel Graune manuel.gra...@koeln.dewrote: in (most) python documentation the syntax list() and [] is treated as being more or less the same thing. For example help([]) and help(list()) point to the same documentation. Since there are at least two cases where

Re: Questions about list-creation

2009-11-30 Thread Luis Zarrabeitia
On Monday 30 November 2009 12:22:17 pm Manuel Graune wrote: when using local variables in list comprehensions, say a=[i for i in xrange(10)] the local variable is not destroyed afterwards: [...] b=list(j for j in xrange(10)) the local variable is destroyed after use: Actually, [] and

Re: Questions about list-creation

2009-11-30 Thread Terry Reedy
Manuel Graune wrote: in (most) python documentation the syntax list() and [] is treated as being more or less the same thing. Untrue. List() and [] happen to both evaluate to the same thing, an empty list. But there is no reason to expect list(sometext) and [sometext] to always evaluate to

problem about list indexing

2006-11-26 Thread hollowspook
Hi, there a = range(100) if I want to use No 7, 11, 56,90 in a, then the only way I do is [a[7], a[11], a[56], a[90]]. Is there any other way? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: problem about list indexing

2006-11-26 Thread John Machin
hollowspook wrote: Hi, there a = range(100) if I want to use No 7, 11, 56,90 in a, then the only way I do is [a[7], a[11], a[56], a[90]]. Is there any other way? I presume a = range(100) is just an indication that a is a list -- the literal answer to your question as asked is simply [7,

Re: problem about list indexing

2006-11-26 Thread Steven D'Aprano
On Sun, 26 Nov 2006 00:25:13 -0800, hollowspook wrote: Hi, there a = range(100) if I want to use No 7, 11, 56,90 in a, then the only way I do is [a[7], a[11], a[56], a[90]]. Is there any other way? a = [7, 11, 56, 90] Are those numbers supposed to be in some sort of series? They

Re: problem about list indexing

2006-11-26 Thread hollowspook
Thanks, John how about indexing 1-7, 10 [range(1:8),10] will generate [[1, 2, 3, 4, 5, 6, 7], 10], instead of [1, 2, 3, 4, 5, 6, 7, 10] John Machin 写道: hollowspook wrote: Hi, there a = range(100) if I want to use No 7, 11, 56,90 in a, then the only way I do is [a[7], a[11], a[56],

Re: problem about list indexing

2006-11-26 Thread bearophileHUGS
hollowspook: how about indexing 1-7, 10 [range(1:8),10] will generate [[1, 2, 3, 4, 5, 6, 7], 10], instead of [1, 2, 3, 4, 5, 6, 7, 10] (Note that range(1:8) is a syntax error). You can join and extend lists as you like: range(1, 8) + [10] [1, 2, 3, 4, 5, 6, 7, 10] See also the list.append

Re: problem about list indexing

2006-11-26 Thread hollowspook
Thanks, bearophile. range(1, 8) + [10] is great! [EMAIL PROTECTED] 写道: hollowspook: how about indexing 1-7, 10 [range(1:8),10] will generate [[1, 2, 3, 4, 5, 6, 7], 10], instead of [1, 2, 3, 4, 5, 6, 7, 10] (Note that range(1:8) is a syntax error). You can join and extend lists as you

Re: problem about list indexing

2006-11-26 Thread ZeD
hollowspook wrote: how about indexing 1-7, 10 [range(1:8),10] will generate [[1, 2, 3, 4, 5, 6, 7], 10], instead of [1, 2, 3, 4, 5, 6, 7, 10] range(1,8)+[10] [1, 2, 3, 4, 5, 6, 7, 10] -- Under construction -- http://mail.python.org/mailman/listinfo/python-list

Re: problem about list indexing

2006-11-26 Thread John Machin
Steven D'Aprano wrote: On Sun, 26 Nov 2006 00:25:13 -0800, hollowspook wrote: Hi, there a = range(100) if I want to use No 7, 11, 56,90 in a, then the only way I do is [a[7], a[11], a[56], a[90]]. Is there any other way? a = [7, 11, 56, 90] Are those numbers supposed to be in

A question about list

2006-10-17 Thread pretoriano_2001
Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! -- http://mail.python.org/mailman/listinfo/python-list

Re: A question about list

2006-10-17 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! a = [[1,1], [2,2]] map( lambda x: x + ['='], a ) [[1, 1, '='], [2, 2, '=']] --

Re: A question about list

2006-10-17 Thread Larry Bates
[EMAIL PROTECTED] wrote: Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! To copy a list use: b=a[:] -Larry -- http://mail.python.org/mailman/listinfo/python-list

Re: A question about list

2006-10-17 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? b = [item + ['='] for item in a] -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for

Re: A question about list

2006-10-17 Thread rzed
[EMAIL PROTECTED] wrote in news:1161102973.920895.141500 @i42g2000cwa.googlegroups.com: Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! b = [[x,y,'='] for (x,y) in a]

Re: A question about list

2006-10-17 Thread Larry Bates
Larry Bates wrote: [EMAIL PROTECTED] wrote: Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! To copy a list use: b=a[:] -Larry Seems I may have misunderstood the

about list

2005-11-20 Thread Shi Mu
How to run a function to make [1,2,4] become [[1,2],1,4],[2,4]]? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: about list

2005-11-20 Thread [EMAIL PROTECTED]
try to describe what you want as it is not very obvious, and has syntax error. Shi Mu wrote: How to run a function to make [1,2,4] become [[1,2],1,4],[2,4]]? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: about list

2005-11-20 Thread Adonis
Shi Mu wrote: How to run a function to make [1,2,4] become [[1,2],1,4],[2,4]]? Thanks! From what I gather try: a = [1,2,4] n = list() for i in a: index = a.index(i) + 1 for x in a[index:]: n.append([i, x]) print n more elegant ways to do this, but its a start. hope this

Re: about list

2005-11-20 Thread rurpy
Shi Mu wrote: How to run a function to make [1,2,4] become [[1,2],1,4],[2,4]]? Thanks! You want [[1,2],[1,4],[2,4]]? That is, all combinations of 2 items from the list? You might want to look at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465 import * from xpermutations [x

Re: about list

2005-11-20 Thread Jeffrey Schwab
[EMAIL PROTECTED] wrote: Shi Mu wrote: How to run a function to make [1,2,4] become [[1,2],1,4],[2,4]]? Thanks! You want [[1,2],[1,4],[2,4]]? That is, all combinations of 2 items from the list? You might want to look at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465