removing an item from a list
hello (again) i'm still stuck at the same point, that is i want to remove an element from an array, let's say i have dtml-let bozo="a,b,c,d" and i want to kill "c", i thought i could make bozo.remove("b") but it doesn't seem to work, so what can i do about it ? thanx, $ven
If the thing in question is really a list not a string as you show here then couldn't you do something like: bozo.del[2] which should delete the third item in the list. ----- Original Message ----- From: "Junk" <junk@gargl.net> To: <zope@zope.org> Sent: Tuesday, June 19, 2001 4:32 PM Subject: [Zope] removing an item from a list
hello (again)
i'm still stuck at the same point, that is i want to remove an element from an array, let's say i have
dtml-let bozo="a,b,c,d"
and i want to kill "c", i thought i could make bozo.remove("b") but it doesn't seem to work, so what can i do about it ?
thanx,
$ven
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
--- If the thing in question is really a list not a string as you show here then couldn't you do something like: bozo.del[2] which should delete the third item in the list. --- problem is i don't know where the string is, i only know it's contents... and it "seems" to behave like a list because i can use _.whrandom.choive(bozo) succesfully on it. i'm still in the dark ;-) $ven
On Tue, 19 Jun 2001, Junk wrote:
--- If the thing in question is really a list not a string as you show here then couldn't you do something like: bozo.del[2] which should delete the third item in the list. ---
problem is i don't know where the string is, i only know it's contents...
and it "seems" to behave like a list because i can use _.whrandom.choive(bozo) succesfully on it.
i'm still in the dark ;-)
$ven
I'd move something like this to Python if its at all possible. There, something like l = ['a','b','c'] x = some_randomizing_stuff() l.remove(x) should work I think? Hth, peter. -- _____________________________________________________________________ peter sabaini, mailto: c c c p@oeh.tu-graz.ac.at "technology: connections that won't, upgrades that can't, hotsyncs that don't, standards that never are, wireless transmittors radiating who knows what..." (wash. post)
Sven, If it's a comma delimited string, you could use: string.split(bozo, ',') to turn it into a list. If you can turn bozo into a list first, things will work the way you want them to. Otherwise, you'll need to use slice operations on the string to remove the elements. Eric.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Junk Sent: Tuesday, June 19, 2001 9:00 AM To: Phil Harris; zope@zope.org Subject: RE: [Zope] removing an item from a list
--- If the thing in question is really a list not a string as you show here then couldn't you do something like: bozo.del[2] which should delete the third item in the list. ---
problem is i don't know where the string is, i only know it's contents...
and it "seems" to behave like a list because i can use _.whrandom.choive(bozo) succesfully on it.
i'm still in the dark ;-)
$ven
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
Eric Walstad -
Junk -
Peter Sabaini -
Phil Harris