Source

pypy / lib_pypy / future_builtins.py

The branch 'remove-globals-in-jit' does not exist.
"""This module provides functions that will be builtins in Python 3.0,
but that conflict with builtins that already exist in Python 2.x.

Functions:

hex(arg) -- Returns the hexadecimal representation of an integer
oct(arg) -- Returns the octal representation of an integer
ascii(arg) -- Same as repr(arg)
map, filter, zip -- Same as itertools.imap, ifilter, izip

The typical usage of this module is to replace existing builtins in a
module's namespace:

from future_builtins import hex, oct
"""

__all__ = ['hex', 'oct', 'ascii', 'map', 'filter', 'zip']

from itertools import imap as map, ifilter as filter, izip as zip

ascii = repr
_builtin_hex = hex
_builtin_oct = oct

def hex(arg):
    return _builtin_hex(arg).rstrip('L')

def oct(arg):
    result = _builtin_oct(arg).rstrip('L')
    if result == '0':
        return '0o0'
    i = result.index('0') + 1
    return result[:i] + 'o' + result[i:]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.