Skip to main content

Python Utils is a module with some convenient utilities not included with the standard Python install

Project description

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')

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

python-utils-2.0.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

python_utils-2.0.0-py2.py3-none-any.whl (7.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file python-utils-2.0.0.tar.gz.

File metadata

File hashes

Hashes for python-utils-2.0.0.tar.gz
Algorithm Hash digest
SHA256 746777e47158641cf97da342dffdc5d1f9901823615d1fdab75ce68ce39194dd
MD5 05d5fba0675e0ba3e3bf367e254d5369
BLAKE2b-256 24f626474b0b52335864cf43a969987b7ab27ee14331def6ec82cbb8263bc937

See more details on using hashes here.

File details

Details for the file python_utils-2.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for python_utils-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 54a3ef7f9c7755be41824c1357ceac07c7f11a9870ed2b3464eee2307a4a2774
MD5 aa180b6363e8db681b4d62525bdf4f18
BLAKE2b-256 48c1f7aa4295833fd17463f83c42be9a154c89169c2f3285f4402700658d15bc

See more details on using hashes here.

Supported by

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