Pythonにはそのための組み込みメカニズムがあります:docstrings。例:
>>> import django.forms
>>> help(django.forms.ModelForm)
Help on class ModelForm in module django.forms.models:
class ModelForm(BaseModelForm)
| Method resolution order:
| ModelForm
| BaseModelForm
| django.forms.forms.BaseForm
| django.utils.encoding.StrAndUnicode
| __builtin__.object
|
| Data and other attributes defined here:
|
| __metaclass__ = <class 'django.forms.models.ModelFormMetaclass'>
|
|
| ----------------------------------------------------------------------
| Methods inherited from BaseModelForm:
|
| __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)
|
| clean(self)
|
| save(self, commit=True)
| Saves this ``form``'s cleaned_data into model instance
| ``self.instance``.
|
| If commit=True, then the changes to ``instance`` will be saved to the
| database. Returns ``instance``.
|
| validate_unique(self)
| Calls the instance's validate_unique() method and updates the form's
| validation errors if any were raised.
|
| ----------------------------------------------------------------------
| Methods inherited from django.forms.forms.BaseForm:
|
| __getitem__(self, name)
| Returns a BoundField with the given name.
|
| __iter__(self)
|
| __unicode__(self)
|
| add_initial_prefix(self, field_name)
| Add a 'initial' prefix for checking dynamic initial values
|
| add_prefix(self, field_name)
| Returns the field name with a prefix appended, if this Form has a
| prefix set.
|
| Subclasses may wish to override.
|
| as_p(self)
| Returns this form rendered as HTML <p>s.
|
| as_table(self)
| Returns this form rendered as HTML <tr>s -- excluding the <table></table>.
|
| as_ul(self)
| Returns this form rendered as HTML <li>s -- excluding the <ul></ul>.
|
| full_clean(self)
| Cleans all of self.data and populates self._errors and
| self.cleaned_data.
|
| has_changed(self)
| Returns True if data differs from initial.
|
| hidden_fields(self)
| Returns a list of all the BoundField objects that are hidden fields.
| Useful for manual form layout in templates.
|
| is_multipart(self)
| Returns True if the form needs to be multipart-encrypted, i.e. it has
| FileInput. Otherwise, False.
|
| is_valid(self)
| Returns True if the form has no errors. Otherwise, False. If errors are
| being ignored, returns False.
|
| non_field_errors(self)
| Returns an ErrorList of errors that aren't associated with a particular
| field -- i.e., from Form.clean(). Returns an empty ErrorList if there
| are none.
|
| visible_fields(self)
| Returns a list of BoundField objects that aren't hidden fields.
| The opposite of the hidden_fields() method.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from django.forms.forms.BaseForm:
|
| changed_data
|
| errors
| Returns an ErrorDict for the data provided for the form
|
| media
| Provide a description of all media required to render the widgets on this form
|
| ----------------------------------------------------------------------
| Methods inherited from django.utils.encoding.StrAndUnicode:
|
| __str__(self)
|
| ----------------------------------------------------------------------
| Data descriptors inherited from django.utils.encoding.StrAndUnicode:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
次に、個々のメソッドのドキュメント文字列を検索できます。
>>> help(django.forms.ModelForm.is_valid)
Help on method is_valid in module django.forms.forms:
is_valid(self) unbound django.forms.models.ModelForm method
Returns True if the form has no errors. Otherwise, False. If errors are
being ignored, returns False.