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

2014-02-19 Thread Marko Rauhamaa
Marko Rauhamaa : > 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-19 Thread Marko Rauhamaa
John O'Hagan : > 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 "", line 1, in > TypeError: 'tuple' object does not support item assignment > > Whether there is an error or not dep

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 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

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. > >

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 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 it's a bit con

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) in () > 1 a[0] += [1] TypeEr

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 Xavier Ho
2010/9/2 Alban Nona > 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

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', 'ELM001_

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 02:49, Alban Nona 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', 'ELM001_MAT', 'ELM001_

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 = ['ELM002_DI

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 01:11, Alban Nona 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, The reason it's

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 > On 2 September 2010 00:47, Alban Nona wrote: > >> Hello, >> >> So

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 00:47, Alban Nona 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, ELM004_ALB, > etc...]

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 [ELM0

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Xavier Ho
On 1 September 2010 12:00, Alban Nona 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

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 > On 01/09/2010 03:00, Alban Nona w

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 sub

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 > On 1 September 2010 07:57, Alban Nona wrote: > >>

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Xavier Ho
On 1 September 2010 07:57, Alban Nona 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. (

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 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) #I

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 > 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_v

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 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 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"] fo

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 wrote: > Ok, here a solution: > 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 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: ["FN067_098_MEN_Hair_PUZ

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)

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: ["FN067_098_MEN_Hair_PUZ_v001.0001.exr","FN067_098_JIN_Hair_SPC_v

Re: question about list extension

2010-04-16 Thread J
On Fri, Apr 16, 2010 at 15:16, Terry Reedy 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

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. 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))) >

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:

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

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 li

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 ea

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: 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 5

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() and [] to always evaluate to the same thing

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, []

Re: Questions about list-creation

2009-11-30 Thread Stephen Hansen
On Mon, Nov 30, 2009 at 9:22 AM, 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 simi

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 compr

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 belo

Re: Questions about list-creation

2009-11-30 Thread Lie Ryan
n xrange(10)] the local variable is not destroyed 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 ge

Re: Questions about list-creation

2009-11-30 Thread inhahe
On Mon, Nov 30, 2009 at 12:22 PM, Manuel Graune 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 cases w

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

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

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 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

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.a

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], > >

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 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 simpl

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: 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 ha

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

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

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-l

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, '=']] >>>

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: 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/Reci

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

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 h

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

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