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.76.00.zip
(9.5 kB
view details)
antipathy-0.76.00.tar.gz
(8.1 kB
view details)
File details
Details for the file antipathy-0.76.00.zip.
File metadata
- Download URL: antipathy-0.76.00.zip
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8637e46d9df4b004697cfb9dc0f456f18acdb4e4e619e8e17bd98dafe49eff5
|
|
| MD5 |
ccd3ea23a45c4b7cf239d96cc4001155
|
|
| BLAKE2b-256 |
6b34b957207f11aa01fef38fb465f661237a150456b7066cb56696051296ad36
|
File details
Details for the file antipathy-0.76.00.tar.gz.
File metadata
- Download URL: antipathy-0.76.00.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ede52cb8231c6e8d84bc289a9896e686aa2b6084e14f9bb2bbe77eef1ae227c1
|
|
| MD5 |
9e8c3b8fa063b7c7690303f8bad515e2
|
|
| BLAKE2b-256 |
c3df452ecbef654f73abf7aee94a19b231e8f981e0fe25343aea18ebb356751c
|