Extension of Python language.
Project description
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, andfrom 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, supportingpandasaccessor.
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'
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f333911e19d8886dc24d32cec2936dd162d8d0c3125bb29eac5e9cad807f58d5
|
|
| MD5 |
6a00f56315ac88e348b9912cb1389a99
|
|
| BLAKE2b-256 |
fffea369766a8e05f44aef23a8697914ec5e7f0ba360e38c51ca10e609fa239c
|
Provenance
The following attestation bundles were made for pprog-0.0.3.tar.gz:
Publisher:
python-publish.yml on pprog-dev/pprogdev
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pprog-0.0.3.tar.gz -
Subject digest:
f333911e19d8886dc24d32cec2936dd162d8d0c3125bb29eac5e9cad807f58d5 - Sigstore transparency entry: 301760345
- Sigstore integration time:
-
Permalink:
pprog-dev/pprogdev@ecf420e04707349f3eaf63d4b3c8943d6de9588e -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/pprog-dev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ecf420e04707349f3eaf63d4b3c8943d6de9588e -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a25d67b2df3e88d6ae269f34850b21db1dc9938cc7b922473467becdea054c53
|
|
| MD5 |
a57aa8cbb10fd87557fc8dc8410a62d9
|
|
| BLAKE2b-256 |
d753b89fa59a378d4204e6e7e6904adae14feb93ed7f14fb75001d4a4c8c8fed
|
Provenance
The following attestation bundles were made for pprog-0.0.3-py3-none-any.whl:
Publisher:
python-publish.yml on pprog-dev/pprogdev
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pprog-0.0.3-py3-none-any.whl -
Subject digest:
a25d67b2df3e88d6ae269f34850b21db1dc9938cc7b922473467becdea054c53 - Sigstore transparency entry: 301760358
- Sigstore integration time:
-
Permalink:
pprog-dev/pprogdev@ecf420e04707349f3eaf63d4b3c8943d6de9588e -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/pprog-dev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ecf420e04707349f3eaf63d4b3c8943d6de9588e -
Trigger Event:
release
-
Statement type: