Is there an easier way to express this list slicing?

2006-11-30 Thread John Henry
If I have a list of say, 10 elements and I need to slice it into irregular size list, I would have to create a bunch of temporary variables and then regroup them afterwords, like: # Just for illustration. Alist can be any existing 10 element list a_list=(,)*10 (a,b,c1,c2,c3,d1,d2,d3,d4,d5)=a_list

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Thomas Ploch
John Henry schrieb: If I have a list of say, 10 elements and I need to slice it into irregular size list, I would have to create a bunch of temporary variables and then regroup them afterwords, like: # Just for illustration. Alist can be any existing 10 element list a_list=(,)*10

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Chris Mellon
On 11/30/06, Thomas Ploch [EMAIL PROTECTED] wrote: John Henry schrieb: If I have a list of say, 10 elements and I need to slice it into irregular size list, I would have to create a bunch of temporary variables and then regroup them afterwords, like: # Just for illustration. Alist can

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread John Henry
Well, pardoon me. Next. Thomas Ploch wrote: John Henry schrieb: If I have a list of say, 10 elements and I need to slice it into irregular size list, I would have to create a bunch of temporary variables and then regroup them afterwords, like: # Just for illustration. Alist can be any

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread mdsteele
John Henry wrote: Can I say something to the effect of: (a,b,c[0:2],d[0:5])=a_list# Obviously this won't work Your best bet is probably: x = [...some list...] a,b,c,d = x[:1],x[1:2],x[2:5],x[5:] I am asking this because I have a section of code that contains *lots* of things like this.

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Neil Cerutti
On 2006-11-30, John Henry [EMAIL PROTECTED] wrote: If I have a list of say, 10 elements and I need to slice it into irregular size list, I would have to create a bunch of temporary variables and then regroup them afterwords, like: # Just for illustration. Alist can be any existing 10 element

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Neil Cerutti
On 2006-11-30, Neil Cerutti [EMAIL PROTECTED] wrote: On 2006-11-30, John Henry [EMAIL PROTECTED] wrote: If I have a list of say, 10 elements and I need to slice it into irregular size list, I would have to create a bunch of temporary variables and then regroup them afterwords, like: # Just

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Paul McGuire
John Henry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] If I have a list of say, 10 elements and I need to slice it into irregular size list, I would have to create a bunch of temporary variables and then regroup them afterwords, like: # Just for illustration. Alist can be any

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Paul McGuire
Paul McGuire [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] John Henry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] snip G... that's what I get for not keeping editor and interpreter windows in sync. My post was referencing vars I had defined in the interpreter,

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread John Henry
[EMAIL PROTECTED] wrote: John Henry wrote: Can I say something to the effect of: (a,b,c[0:2],d[0:5])=a_list# Obviously this won't work Your best bet is probably: x = [...some list...] a,b,c,d = x[:1],x[1:2],x[2:5],x[5:] Dude! Why didn't I think of that (tunnel vision). Thanks,

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread John Henry
Paul McGuire wrote: Paul McGuire [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] John Henry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] snip G... that's what I get for not keeping editor and interpreter windows in sync. My post was referencing vars I had

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread John Henry
John Henry wrote: Paul McGuire wrote: Paul McGuire [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] John Henry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] snip G... that's what I get for not keeping editor and interpreter windows in sync. My post was

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Thomas Ploch
John Henry schrieb: If I have a list of say, 10 elements and I need to slice it into irregular size list, I would have to create a bunch of temporary variables and then regroup them afterwords, like: # Just for illustration. Alist can be any existing 10 element list a_list=(,)*10

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread John Henry
John Henry wrote: Further, if splitUp is a sub-class of string, then I can do: alist, blist, clist, dlist = ABCDEFGHIJ.slice((1,1,3,None)) Now, can I override the slice operator? Maybe like: alist, blist, clist, dlist = newStr(ABCDEFGHIJ)[1,1,3,None] where newStr is a sub-class of str,

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread John Henry
Thomas Ploch wrote: snip I had a little bit of fun while writing this: itemList = (a,b,c1,c2,c3,d1,d2,d3,d4,d5) and itemList2 = (a1,a2,a3,b,c,d1,d2,d3,d4,d5) the next time. Huh? What's a,b,d5? def getSlices(aCount, bCount, cCount, dCount, items): a,b,c,d = (items[0:aCount],

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Thomas Ploch
John Henry schrieb: Thomas Ploch wrote: snip I had a little bit of fun while writing this: itemList = (a,b,c1,c2,c3,d1,d2,d3,d4,d5) and itemList2 = (a1,a2,a3,b,c,d1,d2,d3,d4,d5) the next time. Huh? What's a,b,d5? John Henry schrieb: Thomas Ploch wrote: snip I had a little

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread John Henry
Thomas Ploch wrote: John Henry schrieb: Thomas Ploch wrote: snip I had a little bit of fun while writing this: itemList = (a,b,c1,c2,c3,d1,d2,d3,d4,d5) and itemList2 = (a1,a2,a3,b,c,d1,d2,d3,d4,d5) the next time. Huh? What's a,b,d5? Can be any object, as you

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Paul McGuire
John Henry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] John Henry wrote: Further, if splitUp is a sub-class of string, then I can do: alist, blist, clist, dlist = ABCDEFGHIJ.slice((1,1,3,None)) Now, can I override the slice operator? Maybe like: alist, blist, clist,

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread John Henry
Paul McGuire wrote: John Henry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] John Henry wrote: Further, if splitUp is a sub-class of string, then I can do: alist, blist, clist, dlist = ABCDEFGHIJ.slice((1,1,3,None)) Now, can I override the slice operator? Maybe