Skip to main content

Useful Python Utils

https://travis-ci.org/WoLpH/python-utils.png?branch=master https://coveralls.io/repos/WoLpH/python-utils/badge.png?branch=master

Python Utils is a collection of small Python functions and classes which make common patterns shorter and easier. It is by no means a complete collection but it has served me quite a bit in the past and I will keep extending it.

One of the libraries using Python Utils is Django Utils.

Documentation is available at: http://python-utils.readthedocs.org/en/latest/

Requirements for installing:

  • six any recent version

Installation:

pip install python-utils

Quickstart

This module makes it easy to execute common tasks in Python scripts such as converting text to numbers and making sure a string is in unicode or bytes format.

Examples

To extract a number from nearly every string:

from python_utils import converters

number = converters.to_int('spam15eggs')
assert number == 15

number = converters.to_int('spam')
assert number == 0

number = converters.to_int('spam', default=1)
assert number == 1

number = converters.to_float('spam1.234')

To do a global import programmatically you can use the import_global function. This effectively emulates a from … import *

from python_utils.import_ import import_global

# The following is  the equivalent of `from some_module import *`
import_global('some_module')

Metadata

Release files for python-utils 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-utils 2.0.0
File Size Uploaded Provenance Actions
python-utils-2.0.0.tar.gz 5.5 kB Without provenance Details for python-utils-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-utils 2.0.0
File Interpreter ABI Platform Actions
python_utils-2.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for python_utils-2.0.0-py2.py3-none-any.whl

Total release size: 13.4 kB

Release files / python-utils-2.0.0.tar.gz

Download URL python-utils-2.0.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
746777e47158641cf97da342dffdc5d1f9901823615d1fdab75ce68ce39194dd
BLAKE2b-256 checksum
How to use checksums
24f626474b0b52335864cf43a969987b7ab27ee14331def6ec82cbb8263bc937
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python_utils-2.0.0-py2.py3-none-any.whl

Download URL python_utils-2.0.0-py2.py3-none-any.whl
Size 7.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
54a3ef7f9c7755be41824c1357ceac07c7f11a9870ed2b3464eee2307a4a2774
BLAKE2b-256 checksum
How to use checksums
48c1f7aa4295833fd17463f83c42be9a154c89169c2f3285f4402700658d15bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for python-utils 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page