Skip to main content

A Python extension module.

Project description

PyScratches

PyScratches is a lightweight utility library for Python that allows you to repeat actions, wait for time intervals, and execute functions conditionally or repeatedly. Ideal for simple scripts, quick tests, or basic automation.

Main Functions

repeat(string, times)

Prints a string multiple times.

Parameters:

  • string (str): The text to print.
  • times (int): The number of times to print the text.

Example:

from pyextension import repeat

repeat("Hello", 3)
# Output:
# Hello
# Hello
# Hello

wait(seconds)

Pauses the program execution for a given number of seconds.

Parameters:

seconds (float): Time to wait in seconds.

Example:

from pyextension import wait


wait(2)  # Pauses for 2 seconds
print("Done!")

forever(func, delay=None)

Executes a function indefinitely. Optionally, a delay can be added between each execution.

Parameters:

func (callable): The function to execute.

delay (float, optional): Seconds to wait between executions. Default is None.

Example:

from pyextension import forever

def greet():
print("Hello")

forever(greet, delay=1) # Prints "Hello" every second

when(condition, func)

Executes a function when a condition becomes True (continuously evaluated).

Parameters:

condition (callable → bool): Condition that is checked repeatedly until True.

func (callable): Function to execute when the condition is True.

Example:

from pyextension import when

x = 0

def cond():
return x > 5

def action():
print("x is greater than 5!")

when(cond, action)

until(condition, func)

Executes a function while a condition is True (stops when the condition becomes False).

Parameters:

condition (callable → bool): Condition that is checked continuously.

func (callable): Function to execute when the condition is False.

Example:

from pyextension import until


x = 5


def cond():
    return x > 0


def action():
    print("x is still positive")


until(cond, action)

PyExtension is very simple, but useful for scripts that need to repeat tasks, wait for intervals, or execute functions conditionally without relying on external libraries.

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

pyscratches-0.1.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyscratches-0.1.1-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file pyscratches-0.1.1.tar.gz.

File metadata

  • Download URL: pyscratches-0.1.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for pyscratches-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3b6b0c9905aebf5e7985eb37fa641ec2e9cc7f75bc8a055e9769be0a06c28d42
MD5 9bd3cfb25e355c1083ee391af034de5d
BLAKE2b-256 e2b149a72be44c3a6726124bebae32cb1ee866518cb11504f4823fb996f539e3

See more details on using hashes here.

File details

Details for the file pyscratches-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyscratches-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for pyscratches-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 33ff8fca94019311b6c122eb2117915c0da4884ad1e2e926353a1e44559019be
MD5 2740101c9ce0f143cfd1982ecd8eb2a9
BLAKE2b-256 b7b8562184a2482f71b5669188ec17680db20f358509e75276b58d0e2fcccaca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page