Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | List of all members
pip._vendor.pyparsing.results.ParseResults.List Class Reference
Inheritance diagram for pip._vendor.pyparsing.results.ParseResults.List:
Inheritance graph
[legend]
Collaboration diagram for pip._vendor.pyparsing.results.ParseResults.List:
Collaboration graph
[legend]

Public Member Functions

 __new__ (cls, contained=None)
 

Detailed Description

Simple wrapper class to distinguish parsed list results that should be preserved
as actual Python lists, instead of being converted to :class:`ParseResults`::

    LBRACK, RBRACK = map(pp.Suppress, "[]")
    element = pp.Forward()
    item = ppc.integer
    element_list = LBRACK + pp.DelimitedList(element) + RBRACK

    # add parse actions to convert from ParseResults to actual Python collection types
    def as_python_list(t):
        return pp.ParseResults.List(t.as_list())
    element_list.add_parse_action(as_python_list)

    element <<= item | element_list

    element.run_tests('''
        100
        [2,3,4]
        [[2, 1],3,4]
        [(2, 1),3,4]
        (2,3,4)
        ''', post_parse=lambda s, r: (r[0], type(r[0])))

prints::

    100
    (100, <class 'int'>)

    [2,3,4]
    ([2, 3, 4], <class 'list'>)

    [[2, 1],3,4]
    ([[2, 1], 3, 4], <class 'list'>)

(Used internally by :class:`Group` when `aslist=True`.)

The documentation for this class was generated from the following file: