Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

oo view of file paths and names, subclassed from bytes/str/unicode

Project description

Tired of calling a function for every path manipulation you need to do?

Is:

>>> path, filename = os.path.split(some_name)
>>> basename, ext = os.path.splitext(filename)
>>> basename = basename + '_01'
>>> new_name = os.path.join(path, basename+ext)

wearing on your nerves?

In short, are you filled with antipathy [1] for os.path?

Then get antipathy and work with Path:

>>> from antipathy import Path
>>> some_name = Path('/home/ethan/source/my_file.txt')
>>> backups = Path('/home/ethan/backup/')
>>> print some_name.path
'/home/ethan/source/'
>>> print some_name.ext
'.txt'
>>> print some_name.exists()
True  # (well, if it happens to exist at this moment ;)
>>> backup = backups / some_name.filename + '_01' + some_name.ext
>>> print backup
'/home/ethan/backup/my_file_01.txt'
>>> some_name.copy(backup)

Because Path is a subclass of bytes/str/unicode, it can still be passed to other functions that expect a bytes/str/unicode object and work seamlessly [2].

[1] https://www.google.com/#q=antipathy

[2] in most cases – there are a few places that do a type check instead of an isinstance check.

Project details


Release history Release notifications

This version
History Node

0.82.5

History Node

0.82.4

History Node

0.82.3

History Node

0.82.2

History Node

0.82.1

History Node

0.82.0

History Node

0.81.9

History Node

0.81.7

History Node

0.81.6

History Node

0.81.05

History Node

0.81.04

History Node

0.81.03

History Node

0.81.01

History Node

0.81.00

History Node

0.80.02

History Node

0.80.01

History Node

0.80.00

History Node

0.77.08

History Node

0.77.07

History Node

0.77.06

History Node

0.77.05

History Node

0.77.04

History Node

0.77.03

History Node

0.77.02

History Node

0.77.01

History Node

0.77.00

History Node

0.76.00

History Node

0.75.02

History Node

0.75.00

History Node

0.73.006

History Node

0.73.005

History Node

0.73.004

History Node

0.73.003

History Node

0.73.002

History Node

0.73.001

History Node

0.73.000

History Node

0.72.000

History Node

0.71.003

History Node

0.37.001

History Node

0.33.001

History Node

0.11.013

History Node

0.07.013

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
antipathy-0.82.5-py2.py3-none-any.whl (18.5 kB) Copy SHA256 hash SHA256 Wheel 3.5 Feb 27, 2016
antipathy-0.82.5.tar.gz (16.4 kB) Copy SHA256 hash SHA256 Source None Feb 27, 2016
antipathy-0.82.5.zip (20.0 kB) Copy SHA256 hash SHA256 Source None Feb 27, 2016

Supported by

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