I want this Template class to accept children of itself and other types with type(i) in self._allowed_types
.
class Template():
_allowed_types = [str, Template, SafeHtml]
Above code throws this:
NameError: name 'Template' is not defined
Add the class after the class is defined:
class Template():
_allowed_types = [str, SafeHtml]
Template._allowed_types.append(Template)
The class body, by necessity, is run before the class object can be created, so the name Template
is not defined yet. But you can always alter class attributes after the object has been created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With