You are viewing an older version (5.14.3). Go to latest (5.15.0)
{ } Raw JSON

bundles / traitlets 5.14.3 / traitlets / traitlets / HasTraits / trait_has_value

function

traitlets.traitlets:HasTraits.trait_has_value

source: /traitlets/traitlets.py :1828

Signature

def   trait_has_value ( self name : str )  →  bool

Summary

Returns True if the specified trait has a value.

Extended Summary

This will return false even if getattr would return a dynamically generated default value. These default values will be recognized as existing only after they have been generated.

Example

class MyClass(HasTraits):
    i = Int()

mc = MyClass()
assert not mc.trait_has_value("i")
mc.i  # generates a default value
assert mc.trait_has_value("i")

Aliases

  • traitlets.HasTraits.trait_has_value