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


Python inspect.getcomments方法代碼示例

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


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

示例1: getdoc

# 需要導入模塊: import inspect [as 別名]
# 或者: from inspect import getcomments [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', '', result.rstrip()) or '' 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:6,代碼來源:pydoc.py

示例2: getdoc

# 需要導入模塊: import inspect [as 別名]
# 或者: from inspect import getcomments [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

示例3: getdoc

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

示例4: test_getcomments

# 需要導入模塊: import inspect [as 別名]
# 或者: from inspect import getcomments [as 別名]
def test_getcomments(self):
        self.assertEqual(inspect.getcomments(mod), '# line 1\n')
        self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n') 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:test_inspect.py

示例5: get_doc

# 需要導入模塊: import inspect [as 別名]
# 或者: from inspect import getcomments [as 別名]
def get_doc(obj):
    """Get the doc string or comments for an object.

    :param object: object
    :returns: doc string
    :rtype: str

    >>> get_doc(abs)
    'abs(number) -> number\\n\\nReturn the absolute value of the argument.'
    """
    result = inspect.getdoc(obj) or inspect.getcomments(obj)
    return result and RE_EMPTY_LINE.sub('', result.rstrip()) or '' 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:14,代碼來源:complete_calltip.py

示例6: test_getcomments

# 需要導入模塊: import inspect [as 別名]
# 或者: from inspect import getcomments [as 別名]
def test_getcomments(self):
        self.assertEqual(inspect.getcomments(mod), '# line 1\n')
        self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n')
        # If the object source file is not available, return None.
        co = compile('x=1', '_non_existing_filename.py', 'exec')
        self.assertIsNone(inspect.getcomments(co))
        # If the object has been defined in C, return None.
        self.assertIsNone(inspect.getcomments(list)) 
開發者ID:ShikyoKira,項目名稱:Project-New-Reign---Nemesis-Main,代碼行數:10,代碼來源:test_inspect.py

示例7: get_object_comments

# 需要導入模塊: import inspect [as 別名]
# 或者: from inspect import getcomments [as 別名]
def get_object_comments(obj):
    return inspect.getcomments(obj) 
開發者ID:compas-dev,項目名稱:compas,代碼行數:4,代碼來源:rui.py


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