トップ 一覧 ping 検索 ヘルプ RSS ログイン

Python help関数の使い方の変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
!!!Python help関数の使い方
[Python]
[Python][言語まとめ Python]

!!"対象"に調べたいオブジェクトを設定
 >>> help(対象) 

!ライブラリ等の場合、importしてから使用する
 >>> import fileinput
 >>> help(fileinput)
 Help on module fileinput:
 
 NAME
     fileinput - Helper class to quickly write a loop over all standard input fi
 es.
 
 FILE
     c:\python25\lib\fileinput.py
                 :

!組み込みオブジェクトのHELPを確認する
::組み込みオブジェクト名称を取得
 >>> import pprint
 >>> pprint.pprint(dir(__builtins__))
 ['ArithmeticError',
  'AssertionError',
  'AttributeError',
  'BaseException',
  'DeprecationWarning',
  'EOFError',
  'Ellipsis',
         :
  'str'
         :
  'zip']

::例えば、文字列型のHELPを確認
 >>>help(__builtins__.str)
 Help on class str in module __builtin__: 
 
 class str(basestring)
  |  str(object) -> string
  |
  |  Return a nice string representation of the object.
  |  If the argument is a string, the return value is the same object.
  |
 

!!オブジェクトではない場合、引用符で囲って使用する
 >>> help('print')
   ------------------------------------------------------------------------
 
   6.6 The print statement
 
         print_stmt       ::=     "print" ([expression[1] ("," expression[2])* [","]
                         | ">>" expression[3] [("," expression[4])+ [","])
 
   Download entire grammar as text.[5]
 
   print evaluates each expression in turn and writes the resulting object
   to standard output (see below). If an object is not a string, it is
                 :