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 | 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.81.00.zip
.
File metadata
- Download URL: antipathy-0.81.00.zip
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a621b5e99fb9ee9dc917f793c3a54df4862e9092075d5f0b9736d7bcb25bf013 |
|
MD5 | 62b5f0fb4a4bf53370a81f468ceaf9a7 |
|
BLAKE2b-256 | d063d3e19477816759f1519b5ef4d804e55fc0d7a2214780f61950603d2d5444 |
File details
Details for the file antipathy-0.81.00.tar.gz
.
File metadata
- Download URL: antipathy-0.81.00.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f2f2e7e6ee46f14511bccd21da6c91e196957bfa2d3844203ab66fe54a3f0e0 |
|
MD5 | 2c950d6b2fad6649fa6b9e68275e196a |
|
BLAKE2b-256 | a59e6b98fe3c25bc04f0d0b50e4a5938b67b5fc8779f09be5e14f27f5b58f93c |