(tokens, local_dict, global_dict)
return result
Converts numeric literals to use SymPy equivalents.

    Complex numbers use ``I``; integer literals use ``Integer``, float
    literals use ``Float``, and repeating decimals use ``Rational``.
Converts numeric literals to use SymPy equivalents.
Converts numeric literals to use SymPy equivalents .
def auto_number(tokens, local_dict, global_dict):
    """Converts numeric literals to use SymPy equivalents.

    Complex numbers use ``I``; integer literals use ``Integer``, float
    literals use ``Float``, and repeating decimals use ``Rational``.

    """
    result = []
    prevtoken = ''

    for toknum, tokval in tokens:
        if toknum == NUMBER:
            number = tokval
            postfix = []

            if number.endswith('j') or number.endswith('J'):
                number = number[:-1]
                postfix = [(OP, '*'), (NAME, 'I')]

            if '.' in number or (('e' in number or 'E' in number) and
                    not (number.startswith('0x') or number.startswith('0X'))):
                match = _re_repeated.match(number)

                if match is not None:
                    # Clear repeating decimals, e.g. 3.4[31] -> (3 + 4/10 + 31/990)
                    pre, post, repetend = match.groups()

                    zeros = '0'*len(post)
                    post, repetends = [w.lstrip('0') for w in [post, repetend]]
                                                # or else interpreted as octal

                    a = pre or '0'
                    b, c = post or '0', '1' + zeros
                    d, e = repetends, ('9'*len(repetend)) + zeros

                    seq = [
                        (OP, '('),
                        (NAME,
                         'Integer'), (OP, '('), (NUMBER, a), (OP, ')'),
                        (OP, '+'),
                        (NAME, 'Rational'), (OP, '('), (
                            NUMBER, b), (OP, ','), (NUMBER, c), (OP, ')'),
                        (OP, '+'),
                        (NAME, 'Rational'), (OP, '('), (
                            NUMBER, d), (OP, ','), (NUMBER, e), (OP, ')'),
                        (OP, ')'),
                    ]
                else:
                    seq = [(NAME, 'Float'), (OP, '('),
                           (NUMBER, repr(str(number))), (OP, ')')]
            else:
                seq = [(NAME, 'Integer'), (OP, '('), (
                    NUMBER, number), (OP, ')')]

            result.extend(seq + postfix)
        else:
            result.append((toknum, tokval))

    return result
def auto_number ( tokens , local_dict , global_dict ) : result = [ ] prevtoken = '' for toknum , tokval in tokens : if toknum == NUMBER : number = tokval postfix = [ ] if number . endswith ( 'j' ) or number . endswith ( 'J' ) : number = number [ : - 1 ] postfix = [ ( OP , '*' ) , ( NAME , 'I' ) ] if '.' in number or ( ( 'e' in number or 'E' in number ) and not ( number . startswith ( '0x' ) or number . startswith ( '0X' ) ) ) : match = _re_repeated . match ( number ) if match is not None : # Clear repeating decimals, e.g. 3.4[31] -> (3 + 4/10 + 31/990) pre , post , repetend = match . groups ( ) zeros = '0' * len ( post ) post , repetends = [ w . lstrip ( '0' ) for w in [ post , repetend ] ] # or else interpreted as octal a = pre or '0' b , c = post or '0' , '1' + zeros d , e = repetends , ( '9' * len ( repetend ) ) + zeros seq = [ ( OP , '(' ) , ( NAME , 'Integer' ) , ( OP , '(' ) , ( NUMBER , a ) , ( OP , ')' ) , ( OP , '+' ) , ( NAME , 'Rational' ) , ( OP , '(' ) , ( NUMBER , b ) , ( OP , ',' ) , ( NUMBER , c ) , ( OP , ')' ) , ( OP , '+' ) , ( NAME , 'Rational' ) , ( OP , '(' ) , ( NUMBER , d ) , ( OP , ',' ) , ( NUMBER , e ) , ( OP , ')' ) , ( OP , ')' ) , ] else : seq = [ ( NAME , 'Float' ) , ( OP , '(' ) , ( NUMBER , repr ( str ( number ) ) ) , ( OP , ')' ) ] else : seq = [ ( NAME , 'Integer' ) , ( OP , '(' ) , ( NUMBER , number ) , ( OP , ')' ) ] result . extend ( seq + postfix ) else : result . append ( ( toknum , tokval ) ) return result