OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __new__ (cls, **kwargs) |
def | set (self, *args, **kwargs) |
def | create (cls, kwargs, _factory_fields=None, ignore_extra=False) |
def | serialize (self, format=None) |
def | transform (self, *transformations) |
def | __eq__ (self, other) |
def | __ne__ (self, other) |
def | __hash__ (self) |
def | __setattr__ (self, key, value) |
def | __delattr__ (self, key) |
def | __repr__ (self) |
def | __reduce__ (self) |
def | evolver (self) |
def | remove (self, name) |
![]() | |
def | create (cls, source_data, _factory_fields=None) |
![]() | |
def | __new__ (mcs, name, bases, dct) |
A PClass is a python class with a fixed set of specified fields. PClasses are declared as python classes inheriting from PClass. It is defined the same way that PRecords are and behaves like a PRecord in all aspects except that it is not a PMap and hence not a collection but rather a plain Python object. More documentation and examples of PClass usage is available at https://github.com/tobgu/pyrsistent
def __delattr__ | ( | self, | |
key | |||
) |
def __eq__ | ( | self, | |
other | |||
) |
def __hash__ | ( | self | ) |
def __ne__ | ( | self, | |
other | |||
) |
def __new__ | ( | cls, | |
** | kwargs | ||
) |
def __reduce__ | ( | self | ) |
def __repr__ | ( | self | ) |
def __setattr__ | ( | self, | |
key, | |||
value | |||
) |
def create | ( | cls, | |
kwargs, | |||
_factory_fields = None , |
|||
ignore_extra = False |
|||
) |
Factory method. Will create a new PClass of the current type and assign the values specified in kwargs. :param ignore_extra: A boolean which when set to True will ignore any keys which appear in kwargs that are not in the set of fields on the PClass.
def evolver | ( | self | ) |
Returns an evolver for this object.
def remove | ( | self, | |
name | |||
) |
Remove attribute given by name from the current instance. Raises AttributeError if the attribute doesn't exist.
def serialize | ( | self, | |
format = None |
|||
) |
Serialize the current PClass using custom serializer functions for fields where such have been supplied.
Reimplemented from CheckedType.
def set | ( | self, | |
* | args, | ||
** | kwargs | ||
) |
Set a field in the instance. Returns a new instance with the updated value. The original instance remains unmodified. Accepts key-value pairs or single string representing the field name and a value. >>> from pyrsistent import PClass, field >>> class AClass(PClass): ... x = field() ... >>> a = AClass(x=1) >>> a2 = a.set(x=2) >>> a3 = a.set('x', 3) >>> a AClass(x=1) >>> a2 AClass(x=2) >>> a3 AClass(x=3)
def transform | ( | self, | |
* | transformations | ||
) |
Apply transformations to the currency PClass. For more details on transformations see the documentation for PMap. Transformations on PClasses do not support key matching since the PClass is not a collection. Apart from that the transformations available for other persistent types work as expected.