Revision: 616 http://rpy.svn.sourceforge.net/rpy/?rev=616&view=rev Author: lgautier Date: 2008-08-05 10:52:32 +0000 (Tue, 05 Aug 2008)
Log Message: ----------- docstrings Modified Paths: -------------- branches/rpy_nextgen/rpy/rlike/container.py Modified: branches/rpy_nextgen/rpy/rlike/container.py =================================================================== --- branches/rpy_nextgen/rpy/rlike/container.py 2008-08-05 10:42:58 UTC (rev 615) +++ branches/rpy_nextgen/rpy/rlike/container.py 2008-08-05 10:52:32 UTC (rev 616) @@ -123,8 +123,13 @@ class TaggedList(list): - """ A list for which each item has a 'tag'. """ + """ A list for which each item has a 'tag'. + :param l: list + :param tag: optional sequence of tags + + """ + def __add__(self, tl): try: tags = tl.tags() @@ -176,10 +181,19 @@ #self.__tags.__setslice__(i, j, [None, ]) def append(self, obj, tag = None): + """ Append an object to the list + :param obj: object + :param tag: object + """ super(TaggedList, self).append(obj) self.__tags.append(tag) def extend(self, iterable): + """ Extend the list with an iterable object. + + :param iterable: iterable object + """ + if isinstance(iterable, TaggedList): itertags = iterable.itertags() else: @@ -190,16 +204,34 @@ def insert(self, index, obj, tag=None): + """ + Insert an object in the list + + :param index: integer + :param obj: object + :param tag: object + + """ super(TaggedList, self).insert(index, obj) self.__tags.insert(index, tag) def items(self): - """ Return a tuple of all pairs (tag, item). """ + """ + Return a tuple of all pairs (tag, item). + + :rtype: tuple of 2-element tuples (tag, item) + """ + res = [(tag, item) for tag, item in itertools.izip(self.__tags, self)] return tuple(res) def iterontag(self, tag): - """ iterate on items marked with one given tag. """ + """ + iterate on items marked with one given tag. + + :param tag: object + """ + i = 0 for onetag in self.__tags: if tag == onetag: @@ -207,7 +239,11 @@ i += 1 def itertags(self): - """ iterate on tags. """ + """ + iterate on tags. + + :rtype: iterator + """ for tag in self.__tags: yield tag @@ -237,11 +273,21 @@ def tags(self): - """ Return a tuple of all tags """ + """ + Return a tuple of all tags + + :rtype: tuple + """ res = [x for x in self.__tags] return tuple(res) def settag(self, i, t): - """ Set tag 't' for item 'i'. """ + """ + Set tag 't' for item 'i'. + + :param i: integer (index) + + :param t: object (tag) + """ self.__tags[i] = t This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list