Python classes for traversing n-dimensional parameter spaces
<p>I'm learning python, and to train this, I've decided to do some calculations on a parameter space. In order to traverse this parameter space, I'm looking for classes that can help me on this, or help on how to make them myself. </p>

<p>I have already started coding a class to represent a range, and traverse it from one end to the other, but I would like to be able to have a base class defining the range, and then pull something like a generator from it, except I would like to be able to go both forwards and backwards, as well as start from a custom departing point. My current class looks like this:</p>

<pre class="lang-py prettyprint-override"><code>class Range(object):
    '''
    Represents a range
    '''

    def __init__(self, low, high, step=1):
        '''
        Initializes the range
        '''

        if low &gt;= high:
            raise ValueError(
                "The low value must be set lower than the high value.")
        self._low = low
        self._high = high
        self._step = step

        if (self._high - self._low) % self._step != 0:
            raise ValueError("Not possible to hit end value.")

    def generator(self):
        '''
        Walk the range from the low point to the high point
        '''

        current = self._low
        yield current

        while current != self._high:
            current += self._step
            yield current
</code></pre>

<p>I plan to use the <code>Range</code> class to define the possible values of a parameters in a parameter space. I'm looking for information about things that already exist, which does this, and I should know about, and/or tips on howto make things more 'pythonic'.</p>

<p>I know I could just make a list of all the possible values and use the index, and I might do this for parameters which cannot be defined as a range, but that doesn't work well with very large ranges.
The reason why I use a generator is that I need to track multiple points in the parameter space simultaneously, I just need to be able to go backwards as well. Do I really need to make a custom class for this?</p>

<p><strong>* UPDATE *</strong></p>

<p>Alternative implementation of <code>generator</code> using <code>xrange()</code>:</p>

<pre><code>def generator(self):
    '''
    Walk the range from a departure point to a goal point
    '''

    for value in xrange(self._low, self._high + self._step, self._step):
        yield value
</code></pre>
