pytools.expression.base.CollectionLiteral#
- class pytools.expression.base.CollectionLiteral(brackets, elements)[source]#
A collection literal, e.g., a list, set, tuple, or dictionary.
- Bases
- Metaclasses
- Parameters
brackets (
BracketPair
) – the brackets enclosing the collection
Method summary
Create a logical and expression using this and another expression as operands.
Compare this expression with another for equality.
Calculate the hash code for this expression.
Create a logical not expression using this expression as the operand.
Create a logical or expression using this and another expression as operands.
Render this object as an expression.
Attribute summary
The brackets enclosing this expression's subexpressions.
The expression(s) representing the elements of this expression.
The precedence of this expression, used to determine the need for parentheses.
The subexpression representing the element(s) of this collection literal
A tuple with this expression's subexpression as its only element.
Definitions
- and_(other)#
Create a logical and expression using this and another expression as operands.
- Parameters
other (
Expression
) – other operand to combine with this expression using a logical and- Return type
- Returns
the logical and expression
- eq_(other)#
Compare this expression with another for equality.
For using Python’s native equality operator
==
, seeFrozenExpression
.- Parameters
other (
Expression
) – the expression to compare this expression with- Return type
- Returns
True
if both expressions are equal;False
otherwise
- hash_()#
Calculate the hash code for this expression.
For using Python’s native
hash
function, seeFrozenExpression
.- Return type
- Returns
the hash code for this expression
- not_()#
Create a logical not expression using this expression as the operand.
- Return type
- Returns
the logical not expression
- or_(other)#
Create a logical or expression using this and another expression as operands.
- Parameters
other (
Expression
) – other operand to combine with this expression using a logical or- Return type
- Returns
the logical or expression
- to_expression()#
Render this object as an expression.
- Return type
- Returns
the expression representing this object
- property brackets_: BracketPair#
The brackets enclosing this expression’s subexpressions.
- Return type
- property elements_: tuple[pytools.expression.Expression, ...]#
The expression(s) representing the elements of this expression.
- Return type
- property precedence_: int#
The precedence of this expression, used to determine the need for parentheses.
- Return type
- property subexpression_: pytools.expression.Expression#
The subexpression representing the element(s) of this collection literal
an
Epsilon
expression for an empty collectionan arbitrary expression for a collection with a single element
a
BinaryOperation
with aBinaryOperator.COMMA
operator for collections with two or more elements
- Return type
- property subexpressions_: tuple[pytools.expression.Expression, ...]#
A tuple with this expression’s subexpression as its only element.
- Return type