Coming soon
Project description
dramatic
The dramatic
module includes utilities to cause cause all text output to display character-by-character (it prints dramatically).
There are four primary ways to use the utilities in the dramatic
module:
- As a context manager that temporarily makes output display dramatically
- As a decorator that temporarily makes output display dramatically
- Using a
dramatic.start()
function that makes output display dramatically - Using a
dramatic.print
function to display specific text dramatically
Dramatic Context Manager
The dramatic.output
context manager will temporarily cause all standard output and standard error to display dramatically:
import dramatic
def main():
print("This function prints")
with dramatic.output:
main()
To change the printing speed from the default of 75 characters per second to another value (30 characters per minute in this case) use the at_speed
method:
import dramatic
def main():
print("This function prints")
with dramatic.output.at_speed(30):
main()
Dramatic Decorator
The dramatic.output
decorator will cause all standard output and standard error to display dramatically while the decorated function is running:
import dramatic
@dramatic.output
def main():
print("This function prints")
main()
The at_speed
method works as a decorator as well:
import dramatic
@dramatic.output.at_speed(30)
def main():
print("This function prints")
main()
Manually Starting and Stopping
Instead of enabling dramatic printing temporarily with a context manager or decorator, the dramatic.start
function may be used to enable dramatic printing:
import dramatic
def main():
print("This function prints")
dramatic.start()
main()
The speed
keyword argument may be used to change the printing speed:
import dramatic
def main():
print("This function prints")
dramatic.start(speed=30)
main()
To make only standard output dramatic (but not standard error) pass stderr=False
to start
:
import dramatic
def main():
print("This function prints")
dramatic.start(stderr=False)
main()
To disable dramatic printing, the dramatic.stop
function may be used:
import dramatic
class CustomContextManager:
def __enter__(self):
print("Printing will become dramatic now")
dramatic.start()
def __exit__(self):
dramatic.stop()
print("Dramatic printing has stopped")
Dramatic Print
The dramatic.print
function acts just like the built-in print
function, but it prints dramatically:
import dramatic
dramatic.print("This will print some text dramatically")
Other Features
Pressing Ctrl-C
while text prints dramatically will cause the remaining text-to-be-printed to print immediately.
To start a dramatic Python REPL:
$ python3 -m dramatic
>>>
To dramatically run a Python module:
$ python3 -m dramatic -m this
To dramatically run a Python file:
$ python3 -m dramatic hello_world.py
Credits
This package was inspired by the dramatic
Python Morsels exercise, which was partially inspired by Brandon Rhodes' adventure Python port (which displays its text at 1200 baud).
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
Built Distribution
File details
Details for the file dramatic-0.0.0.tar.gz
.
File metadata
- Download URL: dramatic-0.0.0.tar.gz
- Upload date:
- Size: 3.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.25.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 456df0633af0c41196b8172375674b20cb82e0529f26d30e60a19eff0d0cc036 |
|
MD5 | 14b32e9916316f1fc13c93e6472a5ae6 |
|
BLAKE2b-256 | 44432ed5f6c96225fea1ef22ae9fcf5e37f980907dd6426ff82a712fc37df4cd |
File details
Details for the file dramatic-0.0.0-py3-none-any.whl
.
File metadata
- Download URL: dramatic-0.0.0-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.25.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83934d560fffdabb04e675000bc327e52908372f56d4182c90d282203dcf1316 |
|
MD5 | 91b0729a7c4e645d449338968c8ee6a0 |
|
BLAKE2b-256 | 716254974242c7c2c0bf4e3fb14ae8f704feae668ff929df2eca89731fb3e7ca |