Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(6)  |  Derive(0)  |  Import(0)
Work out which source or compiled file an object was defined in.

        def getfile(object):
    """Work out which source or compiled file an object was defined in."""
    if ismodule(object):
        if hasattr(object, '__file__'):
            return object.__file__
        raise TypeError('{!r} is a built-in module'.format(object))
    if isclass(object):
        object = sys.modules.get(object.__module__)
        if hasattr(object, '__file__'):
            return object.__file__
        raise TypeError('{!r} is a built-in class'.format(object))
    if ismethod(object):
        object = object.im_func
    if isfunction(object):
        object = object.func_code
    if istraceback(object):
        object = object.tb_frame
    if isframe(object):
        object = object.f_code
    if iscode(object):
        return object.co_filename
    raise TypeError('{!r} is not a module, class, method, '
                    'function, traceback, frame, or code object'.format(object))
        


src/p/l/plexnet-HEAD/third_party/generic/pypy/py/code/source.py   plexnet(Download)
        # fallback to 
        fn = (py.std.inspect.getsourcefile(obj) or
              py.std.inspect.getfile(obj))
        fspath = fn and py.path.local(fn) or None
        if fspath:

src/n/u/nupic-linux64-HEAD/lib/python2.6/site-packages/py/_code/source.py   nupic-linux64(Download)
        try:
            fn = (py.std.inspect.getsourcefile(obj) or
                  py.std.inspect.getfile(obj))
        except TypeError:
            return "", -1

src/p/y/py-1.4.20/py/_code/source.py   py(Download)
        try:
            fn = (py.std.inspect.getsourcefile(obj) or
                  py.std.inspect.getfile(obj))
        except TypeError:
            return "", -1

src/p/l/plexnet-HEAD/third_party/generic/pypy/py/log/warning.py   plexnet(Download)
def warn(msg, stacklevel=1, function=None):
    if function is not None:
        filename = py.std.inspect.getfile(function)
        lineno = function.func_code.co_firstlineno
    else:

src/n/u/nupic-linux64-HEAD/lib/python2.6/site-packages/py/_log/warning.py   nupic-linux64(Download)
def warn(msg, stacklevel=1, function=None):
    if function is not None:
        filename = py.std.inspect.getfile(function)
        lineno = py.code.getrawcode(function).co_firstlineno
    else:

src/p/y/py-1.4.20/py/_log/warning.py   py(Download)
def warn(msg, stacklevel=1, function=None):
    if function is not None:
        filename = py.std.inspect.getfile(function)
        lineno = py.code.getrawcode(function).co_firstlineno
    else: