SnippetVamp

Because spending time searching snippets sucks.



ALV 3 XPath 1 abap 9 ahk 1 autohotkey 6 bash 2 cli 2 clipboard 3 excel 1 file 1 file_path 1 greasemonkey 1 javascript 1 python 4 sap 1 screen 1 sql 1 ssh 1 tool 2 tunnel 1

.

Circle through list

Circle through list

class CircleList(list):
    """A list to circle throught""" # itertools.circle only goes one way
    def __init__(self, l, i=0, stop=None):
        super(CircleList, self).__init__(l)
        self.i = i
        self.stop = stop
    def current(self):
        return self[self.i]
    def previous(self):
        self.i -= 1
        if self.i < 0:
            self.i = 0 if self.stop else len(self)-1
        return self[self.i]
    def next(self):
        self.i += 1
        if self.i > len(self)-1:
            self.i = len(self)-1 if self.stop else 0
        return self[self.i]

python

<iframe width="100%" height="506" src="http://ginkobox.fr/vamp/index.php?embed=55c51d182921a" type="text/html"></iframe>

Text only - Permalink - Snippet public post date 07/08/2015

This page's Feed


SnippetVamp 1.84 by Bronco - generated in 0.012 s