[Twisted-Python] [PATCH] remove and index for world's StorableList

jml at ids.org.au jml at ids.org.au
Sat May 17 17:10:12 EDT 2003


Hi guys,

I need these methods. They're untested but they look right-ish.

cheers,
jml


Index: twisted/world/compound.py
===================================================================
RCS file: /cvs/Twisted/twisted/world/compound.py,v
retrieving revision 1.6
diff -u -r1.6 compound.py
--- twisted/world/compound.py   16 May 2003 05:00:28 -0000      1.6
+++ twisted/world/compound.py   17 May 2003 09:47:44 -0000
@@ -227,6 +227,16 @@
         l.sort()
         self[:] = l
  
+    def index(self, x):
+        for i in range(len(self)):
+            if x == self[i]:
+                return i
+        raise ValueError, "StorableList.index(x): x not in list"
+
+    def remove(self, x):
+        del self[self.index(x)]
+
+
 class _Nothing:
     """
     this can stop torg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20030518/97a27df8/attachment.pgp 


More information about the Twisted-Python mailing list