def generate_variables(name, n_vars=<NUM_LIT:1>, hermitian=None, commutative=True):
variables = []<EOL>for i in range(n_vars):<EOL><INDENT>if n_vars > <NUM_LIT:1>:<EOL><INDENT>var_name = '<STR_LIT>' % (name, i)<EOL><DEDENT>else:<EOL><INDENT>var_name = '<STR_LIT:%s>' % name<EOL><DEDENT>if commutative:<EOL><INDENT>if hermitian is None or hermitian:<EOL><INDENT>variables.append(Symbol(var_name, real=True))<EOL><DEDENT>else:<EOL><INDENT>variables.append(Symbol(var_name, complex=True))<EOL><DEDENT><DEDENT>elif hermitian is not None and hermitian:<EOL><INDENT>variables.append(HermitianOperator(var_name))<EOL><DEDENT>else:<EOL><INDENT>variables.append(Operator(var_name))<EOL><DEDENT><DEDENT>return variables<EOL>
Generates a number of commutative or noncommutative variables

    :param name: The prefix in the symbolic representation of the noncommuting
                 variables. This will be suffixed by a number from 0 to
                 n_vars-1 if n_vars > 1.
    :type name: str.
    :param n_vars: The number of variables.
    :type n_vars: int.
    :param hermitian: Optional parameter to request Hermitian variables .
    :type hermitian: bool.
    :param commutative: Optional parameter to request commutative variables.
                        Commutative variables are Hermitian by default.
    :type commutative: bool.

    :returns: list of :class:`sympy.physics.quantum.operator.Operator` or
              :class:`sympy.physics.quantum.operator.HermitianOperator`
              variables or `sympy.Symbol`

    :Example:

    >>> generate_variables('y', 2, commutative=True)
    ￼[y0, y1]