• Home
  • Raw
  • Download

Lines Matching refs:meth

15 adding generated :term:`special method`\s such as :meth:`__init__` and
16 :meth:`__repr__` to user-defined classes. It was originally described
32 Will add, among other things, a :meth:`__init__` that looks like::
86 - ``init``: If true (the default), a :meth:`__init__` method will be
89 If the class already defines :meth:`__init__`, this parameter is
92 - ``repr``: If true (the default), a :meth:`__repr__` method will be
99 If the class already defines :meth:`__repr__`, this parameter is
102 - ``eq``: If true (the default), an :meth:`__eq__` method will be
107 If the class already defines :meth:`__eq__`, this parameter is
110 - ``order``: If true (the default is ``False``), :meth:`__lt__`,
111 :meth:`__le__`, :meth:`__gt__`, and :meth:`__ge__` methods will be
117 If the class already defines any of :meth:`__lt__`,
118 :meth:`__le__`, :meth:`__gt__`, or :meth:`__ge__`, then
121 - ``unsafe_hash``: If ``False`` (the default), a :meth:`__hash__` method
124 :meth:`__hash__` is used by built-in :meth:`hash()`, and when objects are
126 :meth:`__hash__` implies that instances of the class are immutable.
128 intent, the existence and behavior of :meth:`__eq__`, and the values of
131 By default, :func:`dataclass` will not implicitly add a :meth:`__hash__`
133 existing explicitly defined :meth:`__hash__` method. Setting the class
135 described in the :meth:`__hash__` documentation.
137 If :meth:`__hash__` is not explicit defined, or if it is set to ``None``,
138 then :func:`dataclass` *may* add an implicit :meth:`__hash__` method.
140 :meth:`__hash__` method with ``unsafe_hash=True``. This might be the case
144 Here are the rules governing implicit creation of a :meth:`__hash__`
145 method. Note that you cannot both have an explicit :meth:`__hash__`
150 generate a :meth:`__hash__` method for you. If ``eq`` is true and
151 ``frozen`` is false, :meth:`__hash__` will be set to ``None``, marking it
153 :meth:`__hash__` will be left untouched meaning the :meth:`__hash__`
159 :meth:`__setattr__` or :meth:`__delattr__` is defined in the class, then
171 :meth:`__init__` method, which will be defined as::
203 field. This is needed because the :meth:`field` call itself
213 parameter to the generated :meth:`__init__` method.
216 string returned by the generated :meth:`__repr__` method.
219 generated equality and comparison methods (:meth:`__eq__`,
220 :meth:`__gt__`, et al.).
223 included in the generated :meth:`__hash__` method. If ``None`` (the
367 The newly returned object is created by calling the :meth:`__init__`
369 :meth:`__post_init__`, if present, is also called.
373 :meth:`__init__` and :meth:`__post_init__`.
381 rather are initialized in :meth:`__post_init__`, if they're
403 The generated :meth:`__init__` code will call a method named
404 :meth:`__post_init__`, if :meth:`__post_init__` is defined on the
407 passed to :meth:`__post_init__` in the order they were defined in the
408 class. If no :meth:`__init__` method is generated, then
409 :meth:`__post_init__` will not automatically be called.
424 parameters to :meth:`__post_init__`. Also see the warning about how
447 parameters to the generated :meth:`__init__` method, and are passed to
448 the optional :meth:`__post_init__` method. They are not otherwise used
473 by passing ``frozen=True`` to the :meth:`dataclass` decorator you can
475 :meth:`__setattr__` and :meth:`__delattr__` methods to the class. These
479 :meth:`__init__` cannot use simple assignment to initialize fields, and
480 must use :meth:`object.__setattr__`.
485 When the dataclass is being created by the :meth:`dataclass` decorator,
508 The generated :meth:`__init__` method for ``C`` will look like::
521 If a field is excluded from :meth:`__init__` (using ``init=False``)
524 :meth:`__init__` function. This happens because there is no other
591 Raised when an implicitly defined :meth:`__setattr__` or
592 :meth:`__delattr__` is called on a dataclass which was defined with