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.72.000.zip
(8.7 kB
view details)
antipathy-0.72.000.tar.gz
(7.7 kB
view details)
File details
Details for the file antipathy-0.72.000.zip.
File metadata
- Download URL: antipathy-0.72.000.zip
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cacb7e6254242cdc033ae0fb2c188953e55b1e6883106fc7913764ec73772660
|
|
| MD5 |
e56f545210bc24037643ccb0ef3ccf4d
|
|
| BLAKE2b-256 |
1078d827f4fb4fa9c467a2b66a3ee1124caead67cc1350457a3c1a18c75fabed
|
File details
Details for the file antipathy-0.72.000.tar.gz.
File metadata
- Download URL: antipathy-0.72.000.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d568d69c7099aba7071159c5e81d86a9ffeae0f678786264d88606f9af03db14
|
|
| MD5 |
cc27f72e2ec034637932ec5c59ffa3a9
|
|
| BLAKE2b-256 |
cc5289befa357e5e4a8b93438a73c54f8edcfad8a5758702d2c2d3c836ef6799
|