def index(self, gen):
        """Compute index of ``gen`` in ``self.gens``. """
        if gen is None:
            i = 0
        elif isinstance(gen, int):
            i = gen

            if 0 <= i and i < self.ngens:
                pass
            elif -self.ngens <= i and i <= -1:
                i = -i - 1
            else:
                raise ValueError("invalid generator index: %s" % gen)
        elif isinstance(gen, self.dtype):
            try:
                i = self.gens.index(gen)
            except __HOLE__:
                raise ValueError("invalid generator: %s" % gen)
        elif isinstance(gen, string_types):
            try:
                i = self.symbols.index(gen)
            except ValueError:
                raise ValueError("invalid generator: %s" % gen)
        else:
            raise ValueError("expected a polynomial generator, an integer, a string or None, got %s" % gen)

        return i
dataset/ETHPy150Open sympy/sympy/sympy/polys/rings.py/PolyRing.index