Good evening. There is a class (mongoengine):
class BaseMetaDocument(Document): unit = StringField(..., readonly = True) name = StringField(..., readonly = False) active = BooleanField(...) Not all attributes have a readonly property defined, so when outputting to a form I use the code:
... try: readonly = v.readonly except: readonly = False info = dict(..., readonly = readonly) return info Question: can you somehow write "in one line"?