You are here: Home / LBN / Up2date / Core Linux / BastionLinux 36 / python3-pure-eval-0.2.2-1.lbn36.noarch

python3-pure-eval-0.2.2-1.lbn36.noarch

Package Attributes
RPM  python3-pure-eval-0.2.2-1.lbn36.noarch.rpm Architecture  noarch Size  72562 Created  2024/07/01 13:33:30 UTC
Package Specification
Summary Safely evaluate AST nodes without side effects
Group Unspecified
License ZPL
Home Page https://pypi.org/project/pure-eval
Description

pure_eval

This is a Python package that lets you safely evaluate certain AST nodes without triggering arbitrary code that may have unwanted side effects. It can be installed from PyPI: pip install pure_eval

To demonstrate usage, suppose we have an object defined as follows: class Rectangle: def __init__(self, width, height): self.width = width self.height = height

@property def area(self): print("Calculating area...") return self.width * self.height

rect = Rectangle(3, 5)

Given the rect object, we want to evaluate whatever expressions we can in this source code: source = "(rect.width, rect.height, rect.area)"

This library works with the AST, so let's parse the source code and peek inside: import ast

tree = ast.parse(source) the_tuple = tree.body[0].value for node in the_tuple.elts: print(ast.dump(node))

Output: Attribute(value=Name(id=rect, ctx=Load()), attr=width, ctx=Load()) Attribute(value=Name(id=rect, ctx=Load()), at

Requires
rpmlib(PayloadFilesHavePrefix)  
rpmlib(PayloadIsZstd)  
rpmlib(CompressedFileNames)  
rpmlib(PartialHardlinkSets)  
rpmlib(FileDigests)  
Provides
python-pure-eval
python3-pure-eval
python3.10-pure-eval
python3.10dist(pure-eval)
python3dist(pure-eval)
Obsoletes
python-pure-eval

Document Actions