Shows a simplified view of the call stack.
Reason this release was yanked:
Typos make it not work.
Project description
ShowCallStack
Shows a simplified view of the call stack.
This module is similar to Python's built-in traceback
and inspect
modules, but is easier to use and displays more simple output. This module is useful for demonstrating what the call stack looks like during recursive function calls. Simply add a from showcallstack import showCallStack
line and then call showCallStack()
from wherever you wish to see the state of the call stack and the local variables in each call frame.
Example Usage
This program...
from showcallstack import showcallstack
def a():
varA = 42
b()
def b():
varB = 86
c()
def c():
varC = 99
showcallstack()
a()
...outputs this:
The call stack is 3 call(s) deep:
Function/method: a(), Local variables: {'varA': 42}
Function/method: b(), Local variables: {'varB': 86}
Function/method: c(), Local variables: {'varC': 99}
This recursive factorial program...
from showcallstack import showcallstack
def factorial(num):
showcallstack()
if num == 1:
return 1
else:
return num * factorial(num - 1)
factorial(4)
...outputs this:
The call stack is 1 call(s) deep:
Function/method: factorial(), Local variables: {'num': 4}
The call stack is 2 call(s) deep:
Function/method: factorial(), Local variables: {'num': 4}
Function/method: factorial(), Local variables: {'num': 3}
The call stack is 3 call(s) deep:
Function/method: factorial(), Local variables: {'num': 4}
Function/method: factorial(), Local variables: {'num': 3}
Function/method: factorial(), Local variables: {'num': 2}
The call stack is 4 call(s) deep:
Function/method: factorial(), Local variables: {'num': 4}
Function/method: factorial(), Local variables: {'num': 3}
Function/method: factorial(), Local variables: {'num': 2}
Function/method: factorial(), Local variables: {'num': 1}
You can also call the showcallstack.getcallstack()
function to get this output as a list of strings.
Support
If you find this project helpful and would like to support its development, consider donating to its creator on Patreon.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ShowCallStack-0.2.1.tar.gz
.
File metadata
- Download URL: ShowCallStack-0.2.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be2f17313b9b553507be1c0ff5cae972e17bacd705f3bc4902da9365898de873 |
|
MD5 | 958fa5f6a18dc2b4e2e53910541f72c3 |
|
BLAKE2b-256 | da738ce10846781ef66d7f75ae70e71860da2bdb9dbf65fa44c5216c8e29e77e |