Skip to main content

pprog: Python Programming Tools

Install

It can be installed with pip.

pip install --upgrade pprog

It works in both Python 2 and Python 3.

Extension of importlib

  • imputil.reload(obj, update_global=True, update_local=True) provides advanced module and object reloading capabilities for Python, so that developer can modify code without restarting the interpreter.

This function solves key limitations of Python's built-in reloading functionality by:

  • Supporting all import styles: import X, from A import X, and from A import B as X
  • Automatically updating references without requiring reassignment
  • Offering granular control over namespace updates (global and/or local namespace)
  • Compatible to both Python 2.6+ and Python 3.1+

Examples:

# Direct import
from mymodule import myfunction
imputil.reload(myfunction)

# Aliased import
from mymodule import myfunction as myfunction1
imputil.reload(myfunction1)

# Module import
import mymodule
imputil.reload(mymodule)

# Module by name
imputil.reload("mymodule")

Example: Automatically updates references without reassignment:

from mymodule import myfunction
imputil.reload(myfunction)  # Modify myfunction in mymodule.py
print(myfunction([3,1,2]))  # Uses new version

Example: Function Reload with Aliases

from mymodule import myfunction as myfunction1, myfunction as myfunction2
# ... modify myfunction implementation ...
imputil.reload(myfunction1)  # Updates both myfunction1 and myfunction2

Example: Selective Namespace Update

myfunction = None  # Global reference
def f():
    global myfunction
    from mymodule import myfunction
    imputil.reload(myfunction, update_local=False)  # Only update global reference
def f():
    from mymodule import myfunction
    # ... modify calculator ...
    imputil.reload(myfunction, update_global=False)  # Update only the local calc reference

Extension of operator

  • pprog.argchecker(*keys, *, default) instantiates a callable object that checks whether position arguments and/or keyword arguments are all present, with optional default value for missing arguments.
  • pprog.arggetter(*keys, *, default) instantiates a callable object that fetches position arguments and/or keyword arguments, with optional default value for missing arguments.
  • pprog.attrchecker(*attrs, *, default) instantiates a callable object that checks whether the given attribute(s) are all present in its operand, with optional default value for missing attributes.
  • pprog.attrgetter(*attrs, *, default) instantiates a callable object that fetches the given attribute(s) from its operand, with optional default value for missing attributes.
  • pprog.constantcreator(value, /, *, copy=False) instantiates a callable object that returns the same constant when it is called.
  • pprog.itemchecker(*items, *, default) instantiates a callable object that checks whether the given item(s) are all present in its operand, with muti-level keys and optional default value for missing items.
  • pprog.itemgetter(*items, *, default) instantiates a callable object that fetches the given item(s) from its operand, with muti-level keys and optional default value for missing items.
  • pprog.methodcaller(name, *args, **kwargs) instantiates a callable object that calls a method with the given name and arguments, supporting pandas accessor.

Examples:

>>> from pprog import arggetter
>>> getter = arggetter(0)  # get the first positional argument
>>> getter("value", "other_input", key="other_keyword_input")
'value'

>>> from pprog import attrgetter
>>> getter = attrgetter("upper")
>>> getter("test")
'TEST'

>>> from pprog import constantcreator
>>> creator = constantcreator("value")
>>> creator()
'value'

Download files

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

Source Distribution

pprog-0.0.3.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

pprog-0.0.3-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file pprog-0.0.3.tar.gz.

File metadata

  • Download URL: pprog-0.0.3.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pprog-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f333911e19d8886dc24d32cec2936dd162d8d0c3125bb29eac5e9cad807f58d5
MD5 6a00f56315ac88e348b9912cb1389a99
BLAKE2b-256 fffea369766a8e05f44aef23a8697914ec5e7f0ba360e38c51ca10e609fa239c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pprog-0.0.3.tar.gz:

Publisher: python-publish.yml on pprog-dev/pprogdev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pprog-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pprog-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pprog-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a25d67b2df3e88d6ae269f34850b21db1dc9938cc7b922473467becdea054c53
MD5 a57aa8cbb10fd87557fc8dc8410a62d9
BLAKE2b-256 d753b89fa59a378d4204e6e7e6904adae14feb93ed7f14fb75001d4a4c8c8fed

See more details on using hashes here.

Provenance

The following attestation bundles were made for pprog-0.0.3-py3-none-any.whl:

Publisher: python-publish.yml on pprog-dev/pprogdev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

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