xotl.tools.symbols
– Logical values¶
Special logical values like Unset, Undefined, Ignored, Invalid, …
All values only could be True
or False
but are intended in places where
None
is expected to be a valid value or for special Boolean formats.
-
xotl.tools.symbols.
Ignored
= Ignored¶ To be used in arguments that are currently ignored because they are being deprecated. The only valid reason to use
Ignored
is to signal ignored arguments in method’s/function’s signature
-
xotl.tools.symbols.
Invalid
= Invalid¶ To be used in functions resulting in a fail where False could be a valid value.
-
xotl.tools.symbols.
This
= This¶ To be used as a mark for current context as a mechanism of comfort.
-
xotl.tools.symbols.
Undefined
= Undefined¶ False value for local scope use or where
Unset
could be a valid value
-
xotl.tools.symbols.
Unset
= Unset¶ False value, mainly for function parameter definitions, where None could be a valid value.
-
class
xotl.tools.symbols.
boolean
(*args, **kwds)[source]¶ Instances are custom logical values (
True
orFalse
).Special symbols allowing only logical (False or True) values.
For example:
>>> true = boolean('true', True) >>> false = boolean('false') >>> none = boolean('false') >>> unset = boolean('unset') >>> class X: ... attr = None >>> getattr(X(), 'attr') is not None False >>> getattr(X(), 'attr', false) is not false True >>> none is false True >>> false == False True >>> false == unset True >>> false is unset False >>> true == True True
-
class
xotl.tools.symbols.
symbol
(*args, **kwds)[source]¶ Instances are custom symbols.
Symbol instances identify uniquely a semantic concept by its name. Each one has an ordinal value associated.
For example:
>>> ONE2MANY = symbol('ONE2MANY') >>> ONE_TO_MANY = symbol('ONE2MANY') >>> ONE_TO_MANY is ONE2MANY True