當前位置: 首頁>>代碼示例>>Python>>正文


Python __builtin__.object方法代碼示例

本文整理匯總了Python中__builtin__.object方法的典型用法代碼示例。如果您正苦於以下問題:Python __builtin__.object方法的具體用法?Python __builtin__.object怎麽用?Python __builtin__.object使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在__builtin__的用法示例。


在下文中一共展示了__builtin__.object方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: locate

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def locate(path, forceload=0):
    """Locate an object by name or dotted path, importing as necessary."""
    parts = [part for part in split(path, '.') if part]
    module, n = None, 0
    while n < len(parts):
        nextmodule = safeimport(join(parts[:n+1], '.'), forceload)
        if nextmodule: module, n = nextmodule, n + 1
        else: break
    if module:
        object = module
        for part in parts[n:]:
            try: object = getattr(object, part)
            except AttributeError: return None
        return object
    else:
        if hasattr(__builtin__, path):
            return getattr(__builtin__, path)

# --------------------------------------- interactive interpreter interface 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:21,代碼來源:pydoc.py

示例2: render_doc

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
    """Render text documentation, given an object or a path to an object."""
    object, name = resolve(thing, forceload)
    desc = describe(object)
    module = inspect.getmodule(object)
    if name and '.' in name:
        desc += ' in ' + name[:name.rfind('.')]
    elif module and module is not object:
        desc += ' in module ' + module.__name__
    if type(object) is _OLD_INSTANCE_TYPE:
        # If the passed object is an instance of an old-style class,
        # document its available methods instead of its value.
        object = object.__class__
    elif not (inspect.ismodule(object) or
              inspect.isclass(object) or
              inspect.isroutine(object) or
              inspect.isgetsetdescriptor(object) or
              inspect.ismemberdescriptor(object) or
              isinstance(object, property)):
        # If the passed object is a piece of data or an instance,
        # document its available methods instead of its value.
        object = type(object)
        desc += ' object'
    return title % desc + '\n\n' + text.document(object, name) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:26,代碼來源:pydoc.py

示例3: locate

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def locate(path, forceload=0):
    """Locate an object by name or dotted path, importing as necessary."""
    parts = [part for part in split(path, '.') if part]
    module, n = None, 0
    while n < len(parts):
        nextmodule = safeimport(join(parts[:n+1], '.'), forceload)
        if nextmodule: module, n = nextmodule, n + 1
        else: break
    if module:
        object = module
    else:
        object = __builtin__
    for part in parts[n:]:
        try:
            object = getattr(object, part)
        except AttributeError:
            return None
    return object

# --------------------------------------- interactive interpreter interface 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:22,代碼來源:pydoc.py

示例4: _is_bytes_like

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def _is_bytes_like(obj):
    """
    Check whether obj behaves like a bytes object.
    """
    try:
        obj + b''
    except (TypeError, ValueError):
        return False
    return True 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:11,代碼來源:_iotools.py

示例5: getdoc

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or '' 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:6,代碼來源:pydoc.py

示例6: classname

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def classname(object, modname):
    """Get a class name and qualify it with a module name if necessary."""
    name = object.__name__
    if object.__module__ != modname:
        name = object.__module__ + '.' + name
    return name 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:8,代碼來源:pydoc.py

示例7: isdata

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def isdata(object):
    """Check if an object is of a type that probably means it's data."""
    return not (inspect.ismodule(object) or inspect.isclass(object) or
                inspect.isroutine(object) or inspect.isframe(object) or
                inspect.istraceback(object) or inspect.iscode(object)) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:7,代碼來源:pydoc.py

示例8: stripid

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def stripid(text):
    """Remove the hexadecimal id from a Python object representation."""
    # The behaviour of %p is implementation-dependent in terms of case.
    return _re_stripid.sub(r'\1', text) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:6,代碼來源:pydoc.py

示例9: classify_class_attrs

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def classify_class_attrs(object):
    """Wrap inspect.classify_class_attrs, with fixup for data descriptors."""
    def fixup(data):
        name, kind, cls, value = data
        if inspect.isdatadescriptor(value):
            kind = 'data descriptor'
        return name, kind, cls, value
    return map(fixup, inspect.classify_class_attrs(object))

# ----------------------------------------------------- module manipulation 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:12,代碼來源:pydoc.py

示例10: fail

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def fail(self, object, name=None, *args):
        """Raise an exception for unimplemented types."""
        message = "don't know how to document object%s of type %s" % (
            name and ' ' + repr(name), type(object).__name__)
        raise TypeError, message 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:7,代碼來源:pydoc.py

示例11: getdocloc

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def getdocloc(self, object):
        """Return the location of module docs or None"""

        try:
            file = inspect.getabsfile(object)
        except TypeError:
            file = '(built-in)'

        docloc = os.environ.get("PYTHONDOCS",
                                "http://docs.python.org/library")
        basedir = os.path.join(sys.exec_prefix, "lib",
                               "python"+sys.version[0:3])
        if (isinstance(object, type(os)) and
            (object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
                                 'marshal', 'posix', 'signal', 'sys',
                                 'thread', 'zipimport') or
             (file.startswith(basedir) and
              not file.startswith(os.path.join(basedir, 'site-packages')))) and
            object.__name__ not in ('xml.etree', 'test.pydoc_mod')):
            if docloc.startswith("http://"):
                docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__)
            else:
                docloc = os.path.join(docloc, object.__name__ + ".html")
        else:
            docloc = None
        return docloc

# -------------------------------------------- HTML documentation generator 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:30,代碼來源:pydoc.py

示例12: repr

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def repr(self, object):
        return Repr.repr(self, object) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:4,代碼來源:pydoc.py

示例13: classlink

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def classlink(self, object, modname):
        """Make a link for a class."""
        name, module = object.__name__, sys.modules.get(object.__module__)
        if hasattr(module, name) and getattr(module, name) is object:
            return '<a href="%s.html#%s">%s</a>' % (
                module.__name__, name, classname(object, modname))
        return classname(object, modname) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:9,代碼來源:pydoc.py

示例14: modulelink

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def modulelink(self, object):
        """Make a link for a module."""
        return '<a href="%s.html">%s</a>' % (object.__name__, object.__name__) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:5,代碼來源:pydoc.py

示例15: formatvalue

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import object [as 別名]
def formatvalue(self, object):
        """Format an argument default value as text."""
        return self.grey('=' + self.repr(object)) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:5,代碼來源:pydoc.py


注:本文中的__builtin__.object方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。