Code Monkey home page Code Monkey logo

python-utils's Introduction

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/

Links

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

python-utils's People

Contributors

wolph avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.