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
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
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
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
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.
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
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
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
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,
[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,
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
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
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
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,
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],
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
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
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,
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
19 matches
Mail list logo