Skip to main content

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


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.82.5.zip (20.0 kB view details)

Uploaded Source

antipathy-0.82.5.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

antipathy-0.82.5-py2.py3-none-any.whl (18.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file antipathy-0.82.5.zip.

File metadata

  • Download URL: antipathy-0.82.5.zip
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for antipathy-0.82.5.zip
Algorithm Hash digest
SHA256 9d93d95a754e4c9d5bbdf71310774aa49be1d3d4db2901258634a3ce2f997a14
MD5 848013b862bc0ed5492582b39affb370
BLAKE2b-256 308e062a1adf561556ca581bd12be2f635c0393c9f7cd47eeb7a6b6eeab251f5

See more details on using hashes here.

File details

Details for the file antipathy-0.82.5.tar.gz.

File metadata

  • Download URL: antipathy-0.82.5.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for antipathy-0.82.5.tar.gz
Algorithm Hash digest
SHA256 883cc847c29065e85d07fce8965d0e32e3ee5cb0d0fdb51a7d8d068b2f87320a
MD5 08c266164da7e8872f2bea1d2d40eb96
BLAKE2b-256 ff27e6aa890c94d76333701c041a7cdb258c18444f3243da55ee7bd863f3006a

See more details on using hashes here.

File details

Details for the file antipathy-0.82.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for antipathy-0.82.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 74ec44edb2a542d15a1facdffed81b55f9303b5ab7195048ee1dfe1d71371898
MD5 99cc0b1e9cbaf6e8f280d8b06c1740bd
BLAKE2b-256 d6672cfa2e78bf61c5df830828e8d260c51386f1f789d00eadc19ee877f37398

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page