Simpler, cleaner access to regular expressions. Globs too.
Project description
A simplified interface to Python’s regular expression (re) string search. Eliminates steps and provides simpler access to results. As a bonus, also provides compatible way to access Unix glob searches.
Usage
Python regular expressions are powerful, but the language’s lack of an en passant (in passing) assignment requires a preparatory motion and then a test:
import re match = re.search(pattern, some_string) if match: print match.group(1)
With simplere, you can do it in fewer steps:
from simplere import * if match / re.search(pattern, some_string): print match[1]
That’s particularly valuable in complex search-and-manipulate code that requires multiple levels of searching along with pre-conditions, error checking, and post-match cleanup, formatting, and actions.
As a bonus, simplere also provides simple glob access.:
if 'globtastic' in Glob('glob*'): print "Yes! It is!" else: raise ValueError('OH YES IT IS!')
See Read the Docs for the full installation and usage documentation.
Notes
See CHANGES.rst for a historical view of changes.
Automated multi-version testing managed with pytest and tox. Continuous integration testing with Travis-CI. Packaging linting with pyroma.
Successfully packaged for, and tested against, all late-model versions of Python: 2.6, 2.7, 3.2, 3.3, 3.4, and 3.5 pre-release (3.5.0b3) as well as PyPy 2.6.0 (based on 2.7.9) and PyPy3 2.4.0 (based on 3.2.5).
The author, Jonathan Eunice or @jeunice on Twitter welcomes your comments and suggestions.
Installation
To install or upgrade to the latest version:
pip install -U simplere
To easy_install under a specific Python version (3.3 in this example):
python3.3 -m easy_install --upgrade simplere
(You may need to prefix these with sudo to authorize installation. In environments without super-user privileges, you may want to use pip’s --user option, to install only for a single user, rather than system-wide.)
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 Distributions
Built Distribution
Hashes for simplere-1.0.10-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a701ef35a371e859f8463ad8a4f66a48a06af88ad8c6f8475743dc040ee82f5 |
|
MD5 | e80c4d84580b2e3f434c9ca7dceed71f |
|
BLAKE2b-256 | 1343bb713811ee619792c0f8d6d3bfebcc9ebb60c2048f2bd9263aef510d341b |