bundles / traitlets latest / traitlets / traitlets / Instance / __init__
function
traitlets.traitlets:Instance.__init__
source: /traitlets/traitlets.py :2256
Signature
def __init__ ( self , klass : str | type[T] | None = None , args : tuple[t.Any, ...] | None = None , kw : dict[str, t.Any] | None = None , allow_none : bool = False , read_only : bool | None = None , help : str | None = None , ** kwargs : t.Any ) → None Summary
Construct an Instance trait.
Extended Summary
This trait allows values that are instances of a particular class or its subclasses. Our implementation is quite different from that of enthough.traits as we don't allow instances to be used for klass and we handle the args and kw arguments differently.
Parameters
klass: class, strThe class that forms the basis for the trait. Class names can also be specified as strings, like 'foo.bar.Bar'.
args: tuplePositional arguments for generating the default value.
kw: dictKeyword arguments for generating the default value.
allow_none: bool [ default False ]Indicates whether None is allowed as a value.
**kwargsExtra kwargs passed to ClassBasedTraitType
Notes
If both args and kw are None, then the default value is None. If args is a tuple and kw is a dict, then the default is created as klass(*args, **kw). If exactly one of args or kw is None, the None is replaced by () or {}, respectively.
Aliases
-
traitlets.Instance.__init__