Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79986

ANN: Antipathy v0.8

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ethan@stoneleaf.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'url:pypi': 0.03; 'subject:ANN': 0.07; 'filename': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'runs': 0.10; 'python': 0.11; '[2].': 0.16; 'basename': 0.16; 'check.': 0.16; 'path:': 0.16; 'subclass': 0.16; "skip:' 30": 0.19; '>>>': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; "haven't": 0.24; 'function': 0.29; 'testing': 0.29; 'skip:p 30': 0.29; '[1]': 0.29; '[2]': 0.30; 'that.': 0.31; 'skip:= 40': 0.31; 'compatible': 0.32; 'url:python': 0.33; 'cases': 0.33; 'moment': 0.34; 'there': 0.35; 'ext': 0.36; 'url:org': 0.36; 'skip:o 20': 0.38; 'filled': 0.38; 'tired': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'expect': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'most': 0.60; 'received:173': 0.61; 'places': 0.64; 'forward,': 0.84; 'short,': 0.84
Date Thu, 30 Oct 2014 18:25:30 -0700
From Ethan Furman <ethan@stoneleaf.us>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
MIME-Version 1.0
To Python <python-list@python.org>
Subject ANN: Antipathy v0.8
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15339.1414718741.18130.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1414718741 news.xs4all.nl 2942 [2001:888:2000:d::a6]:39765
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:79986

Show key headers only | View raw


has just been made compatible with Python 3!  It runs on everything from 2.4 forward, haven't testing anything prior to 
that.

It is available for download at https://pypi.python.org//pypi/antipathy

-------------------------------------------------------------------------------

Antipathy -- for those tired of ``os.path``
===========================================

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 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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

ANN:  Antipathy v0.8 Ethan Furman <ethan@stoneleaf.us> - 2014-10-30 18:25 -0700

csiph-web