Evaluate the match expression. :param matcher: A callback which determines whether an identifier matches or not. See the :class:`ExpressionMatcher` protocol for details and example. :returns: Whether the expression matches or not. :raises UsageError
(self, matcher: ExpressionMatcher)
| 338 | return Expression(input, code) |
| 339 | |
| 340 | def evaluate(self, matcher: ExpressionMatcher) -> bool: |
| 341 | """Evaluate the match expression. |
| 342 | |
| 343 | :param matcher: |
| 344 | A callback which determines whether an identifier matches or not. |
| 345 | See the :class:`ExpressionMatcher` protocol for details and example. |
| 346 | |
| 347 | :returns: Whether the expression matches or not. |
| 348 | |
| 349 | :raises UsageError: |
| 350 | If the matcher doesn't support the expression. Cannot happen if the |
| 351 | matcher supports all expressions. |
| 352 | """ |
| 353 | return bool(eval(self._code, {"__builtins__": {}}, MatcherAdapter(matcher))) |