oo view of file paths and names, subclassed from 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:
>>> 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 str/unicode, it can still be passed to other functions that expect a str/unicode object and work seamlessly.
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
antipathy-0.37.001.zip
(8.2 kB
view details)
antipathy-0.37.001.tar.gz
(7.3 kB
view details)
File details
Details for the file antipathy-0.37.001.zip.
File metadata
- Download URL: antipathy-0.37.001.zip
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a6175289c0b4d6faa1cd54f94b1f81fd4242276edc71df29ceecee266e3962b
|
|
| MD5 |
8838758ff4968ecbaf8c6ff6053620ee
|
|
| BLAKE2b-256 |
c1563f0f1f0e9437b87ef1b186b91248854e5ad378f075a6a5ef1df3173d0e61
|
File details
Details for the file antipathy-0.37.001.tar.gz.
File metadata
- Download URL: antipathy-0.37.001.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dc683a0ccddd2de6e056a6f45dc54cf5858add221003aeaac84f735bf5dd388
|
|
| MD5 |
4939352714f12becbb5df532ef22de19
|
|
| BLAKE2b-256 |
c8b0744548ab3c9c3b4894e545eea3caf9bd3ce37b94013ea61f74747d32dccb
|