module documentation

Module demonstrating the constant representations.

Constant A_DICT The value of a constant is rendered with syntax highlighting. Internal and external links are generated to references of classes/functions used inside the constant
Constant A_LIST Nested objects are colorized.
Constant A_MULTILINE_STRING Multiline strings are always rendered in triple quotes.
Constant A_STIRNG Strings are always rendered in single quotes, and appropriate escaping is added when required.
Constant FUNCTION_CALL Function calls are colorized.
Constant OPERATORS Operators are colorized and parenthesis are added when syntactically required.
Constant RE_MULTILINE Multiline regex patterns are rendered as string.
Constant RE_STR Regular expressions have special colorizing that add syntax highlight to the regex components.
Constant RE_WITH_UNICODE Unicode is supported in regular expressions.
Constant UNSUPPORTED A lot of objects can be colorized: function calls, strings, lists, dicts, sets, frozensets, operators, annotations, names, compiled regular expressions, etc. But when dealing with usupported constructs, like lamba functions, it will display the value without colorization.

The value of a constant is rendered with syntax highlighting. Internal and external links are generated to references of classes/functions used inside the constant

Value
{'1': 33,
 '2': [1, 2, 3, {7: 'oo' * 20}],
 '3': demo_fields_docstring_arguments,
 '4': _PrivateClass.method_inside_private,
 '5': re.compile(r'^<(?P<descr>.*) at (?P<addr>0x[0-9a-f]+)>$')}

Nested objects are colorized.

Value
[1, 2, [5, 6, [(11, 22, 33), 9], 10], 11] + [99, 98, 97, 96, 95]
A_MULTILINE_STRING: str = (source)

Multiline strings are always rendered in triple quotes.

Value
'''Dieu se rit des hommes qui déplorent les effets dont ils cherrissent les caus
es.

Jacques-Bénigne BOSSUET.'''
A_STIRNG: str = (source)

Strings are always rendered in single quotes, and appropriate escaping is added when required.

Continuing lines are wrapped with symbol: "↵" after reaching the maximum number of caracters per line (defaults to 80), change this value with option --pyval-repr-linelen.

Unicode is supported.

Value
'L\'humour, c\'est l\'arme blanche des hommes désarmés; c\'est une déclaration d
e supériorité de l\'humain sur ce qui lui arrive 😀. Romain GARY.'
FUNCTION_CALL = (source)

Function calls are colorized.

Value
list(range(100)) + [99, 98, 97, 96, 95]
OPERATORS = (source)

Operators are colorized and parenthesis are added when syntactically required.

Value
1 << (10 | 1) << 1
RE_MULTILINE = (source)

Multiline regex patterns are rendered as string.

"..." is added when reaching the maximum number of lines for constant representation (defaults to 7), change this value with option --pyval-repr-maxlines.

Value
re.compile('''
    # Source consists of a PS1 line followed by zero or more PS2 lines.
    (?P<source>
        (?:^(?P<indent> [ ]*) >>>    .*)    # PS1 line
        (?:\\n           [ ]*  \\.\\.\\. .*)*   # PS2 lines
        \\n?)
    # Want consists of any non-blank lines that do not start with PS1.
...

Regular expressions have special colorizing that add syntax highlight to the regex components.

Value
re.compile(r'(foo (?P<a>bar) | (?P<boop>baz))')
RE_WITH_UNICODE = (source)

Unicode is supported in regular expressions.

Value
re.compile(r'abc 😀')
UNSUPPORTED = (source)

A lot of objects can be colorized: function calls, strings, lists, dicts, sets, frozensets, operators, annotations, names, compiled regular expressions, etc. But when dealing with usupported constructs, like lamba functions, it will display the value without colorization.

Value
lambda x: demo_fields_docstring_arguments(x, 0) // 2