OpenQuizz
Une application de gestion des contenus pédagogiques
Attribute Class Reference
Inheritance diagram for Attribute:
Collaboration diagram for Attribute:

Public Member Functions

def __init__ (self, name, default, validator, repr, cmp, hash, init, inherited, metadata=None, type=None, converter=None, kw_only=False, eq=None, eq_key=None, order=None, order_key=None, on_setattr=None)
 
def __setattr__ (self, name, value)
 
def from_counting_attr (cls, name, ca, type=None)
 
def cmp (self)
 
def evolve (self, **changes)
 
def __getstate__ (self)
 
def __setstate__ (self, state)
 

Detailed Description

*Read-only* representation of an attribute.

Instances of this class are frequently used for introspection purposes
like:

- `fields` returns a tuple of them.
- Validators get them passed as the first argument.
- The *field transformer* hook receives a list of them.

:attribute name: The name of the attribute.
:attribute inherited: Whether or not that attribute has been inherited from
    a base class.

Plus *all* arguments of `attr.ib` (except for ``factory``
which is only syntactic sugar for ``default=Factory(...)``.

.. versionadded:: 20.1.0 *inherited*
.. versionadded:: 20.1.0 *on_setattr*
.. versionchanged:: 20.2.0 *inherited* is not taken into account for
    equality checks and hashing anymore.
.. versionadded:: 21.1.0 *eq_key* and *order_key*

For the full version history of the fields, see `attr.ib`.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  name,
  default,
  validator,
  repr,
  cmp,
  hash,
  init,
  inherited,
  metadata = None,
  type = None,
  converter = None,
  kw_only = False,
  eq = None,
  eq_key = None,
  order = None,
  order_key = None,
  on_setattr = None 
)

Member Function Documentation

◆ __getstate__()

def __getstate__ (   self)
Play nice with pickle.

◆ __setattr__()

def __setattr__ (   self,
  name,
  value 
)

◆ __setstate__()

def __setstate__ (   self,
  state 
)
Play nice with pickle.

◆ cmp()

def cmp (   self)
Simulate the presence of a cmp attribute and warn.

◆ evolve()

def evolve (   self,
**  changes 
)
Copy *self* and apply *changes*.

This works similarly to `attr.evolve` but that function does not work
with ``Attribute``.

It is mainly meant to be used for `transform-fields`.

.. versionadded:: 20.3.0

◆ from_counting_attr()

def from_counting_attr (   cls,
  name,
  ca,
  type = None 
)

The documentation for this class was generated from the following file: