'Default constructor.
It takes a single argument ``n`` which gives the dimension of the Gray
code. The starting Gray code string (``start``) or the starting ``rank``
may also be given; the default is to start at rank = 0 (\'0...0\').
Examples
>>> from sympy.combinatorics.graycode import GrayCode
>>> a = GrayCode(3)
>>> a
GrayCode(3)
>>> a.n
3
>>> a = GrayCode(3, start=\'100\')
>>> a.current
\'100\'
>>> a = GrayCode(4, rank=4)
>>> a.current
\'0110\'
>>> a.rank
4'

def __new__(cls, n, *args, **kw_args):

    if ((n < 1) or (int(n) != n)):
        raise ValueError(('Gray    code    dimension    must    be    a    positive    integer,    not    %i' % n))
    n = int(n)
    args = ((n,) + args)
    obj = Basic.__new__(cls, *args)
    if ('start' in kw_args):
        obj._current = kw_args['start']
        if (len(obj._current) > n):
            raise ValueError(('Gray    code    start    has    length    %i    but    should    not    be    greater    than    %i' % (len(obj._current), n)))
    elif ('rank' in kw_args):
        if (int(kw_args['rank']) != kw_args['rank']):
            raise ValueError(('Gray    code    rank    must    be    a    positive    integer,    not    %i' % kw_args['rank']))
        obj._rank = (int(kw_args['rank']) % obj.selections)
        obj._current = obj.unrank(n, obj._rank)
    return obj
