jangada.serialization.Serializable.__init__#
- Serializable.__init__(*args, **kwargs) None#
Initialize a Serializable object.
Supports three initialization modes: 1. From keyword arguments: obj = MyClass(prop1=val1, prop2=val2) 2. Copy constructor: obj2 = MyClass(obj1) 3. Internal use during deserialization
- Parameters:
- *argstuple
If empty, initialize from kwargs. If one Serializable instance, perform copy construction.
- **kwargsdict
Property names mapped to values.
- Raises:
- ValueError
If args don’t match a supported signature, or if kwargs contain properties not defined on the class.
Examples
Initialize from kwargs:
>>> class MyClass(Serializable): ... value = SerializableProperty(default=0) ... >>> obj = MyClass(value=42) >>> obj.value 42
Copy constructor:
>>> obj2 = MyClass(obj) >>> obj2.value 42 >>> obj2 is obj False