Skip to main content

('Tools for stack-usage in Python expressions',)

Project description

This small utility package provides functions to be used inside Python expressions that provide functionality like that available in stack-based languages (such as forth and postscript).

It registers a hidden variable in the current running frame, which is a plain Python list - calls to plain “push, pop, dup, retr”, etc… will just push/recover elements from that list.

The intent is that whenever in an expression a value is complicated to retrieve - (or computationally extensive) - instead of having to retrieve it in a previous line and storing said value in a variable, one gets the ability to “push” the value in this implicit stack - and retrieve it in another part of the same expression:

result = pop().upper() if not push(get_my+expensive_value()).isdigit() else pop()

For conveninece, most functions return the valued passed to them in the first place (like the push above).

Possibly in the future a decorator could be provided to modify the bytecode of calling the functions defined in here to make use of the actual value stack running inside the Python VM. Then this will be fun

João S. O. Bueno <>

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stackfull-0.9.tar.gz (3.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page