Skip to main content

Function form removing characters from both sides of string.

Project description


Function form removing characters from both sides of string.


There is just one function remove_hairs() and one decorator remove_hairs_decorator().


This function is useful, when you have string and you need to remove some characters from both sides of the string.

>>> from remove_hairs import remove_hairs
>>> remove_hairs(",a-sd,-/")

By default, the function uses set of characters defined in .HAIRS, which is defined as /:;,- []<>(). You can change that using hairs parameter:

>>> remove_hairs(" - a sd: --", " -")
'a sd:'


As the name say, remove_hairs_decorator() is just decorator for remove_hairs():

def x():
    return ",a-sd,-/"

assert x() == "a-sd"

Or with hairs parameter:

@remove_hairs_decorator(hairs=" -")
def y():
    return " - a sd: --"

assert y() == "a sd:"


The code is hosted at PYPI, and you can easily install it using the following command:

sudo pip install remove_hairs


This project uses py.test for testing. Just run py.test from the root of the project:

$ py.test
============================= test session starts ==============================
platform linux2 -- Python 2.7.6 -- py-1.4.26 -- pytest-2.6.4
collected 2 items

tests/ ..

=========================== 2 passed in 0.02 seconds ===========================



  • Fixed


  • Project created.

Project details

Download files

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

Files for remove_hairs, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size remove_hairs-1.0.1.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page