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
File details
Details for the file antipathy-0.33.001.zip.
File metadata
- Download URL: antipathy-0.33.001.zip
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ad349a334459067694648ced965aa94e30b1febba98caac6aba402b6fdd61a1
|
|
| MD5 |
4a961ba85df0a3bf671ff75c6186eb8d
|
|
| BLAKE2b-256 |
9a4e172fcb26977480bbf52faaf6a49f50c62c5a9069c6ff390838976650b435
|
File details
Details for the file antipathy-0.33.001.tar.gz.
File metadata
- Download URL: antipathy-0.33.001.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a6c2fa1bb4610897df495a9150796cf94f9d501d9567820f620c90b88e2ad39
|
|
| MD5 |
7b90b237687d40e2e75275b51d6aefa2
|
|
| BLAKE2b-256 |
e3ea8b8b22132362e0b9e95ff60933c8fae2c399a081e1b8581636464d7b88f5
|