Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-announce-list@python.org Delivered-To: python-announce-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'attribute': 0.07; 'paths': 0.07; 'url:bitbucket': 0.07; 'url:pypi': 0.08; 'python': 0.08; 'from:addr:pitrou.net': 0.09; 'from:addr:solipsis': 0.09; 'skip:[ 30': 0.09; 'tracker,': 0.09; 'examples': 0.15; 'antoine': 0.16; 'directory::': 0.16; 'eliminating': 0.16; 'filesystem': 0.16; 'from:name:antoine pitrou': 0.16; 'ignores': 0.16; 'navigating': 0.16; 'objects:': 0.16; 'operators,': 0.16; 'paths.': 0.16; 'received:195.5.228': 0.16; 'received:195.5.228.11': 0.16; 'received:213.41.240': 0.16; 'received:213.41.240.54': 0.16; 'received:ap.vmr.nerim.net': 0.16; 'received:charlus.yi.org': 0.16; 'received:vmr.nerim.net': 0.16; 'received:yi.org': 0.16; 'repository:': 0.16; '>>>': 0.18; '3.2': 0.18; 'calls.': 0.23; 'download:': 0.23; 'releasing': 0.23; 'string': 0.24; 'windows': 0.26; 'classes': 0.26; 'module': 0.26; 'skip:[ 10': 0.27; 'import': 0.27; "i'm": 0.27; '(you': 0.28; 'importing': 0.28; "skip:' 10": 0.29; '--------': 0.29; 'skip:p 30': 0.29; 'semantics': 0.30; 'types.': 0.30; 'source': 0.32; 'done': 0.33; 'vs.': 0.34; 'probably': 0.35; '...': 0.35; 'install': 0.35; 'issue': 0.35; 'url:python': 0.36; 'example,': 0.36; 'comparing': 0.36; 'to:addr:python-announce-list': 0.36; 'skip:" 10': 0.36; 'received:org': 0.37; 'hello,': 0.37; 'using': 0.37; 'url:docs': 0.39; 'url:en': 0.39; 'url:org': 0.39; 'files': 0.39; 'to:addr:python.org': 0.40; 'offers': 0.60; 'more': 0.61; 'header:Received:6': 0.61; 'message-id:@localhost.localdomain': 0.78; 'advantages': 0.80; 'querying': 0.84; 'semantics,': 0.84 X-Virus-Scanned: amavisd-new at nerim.net Subject: pathlib 0.4 From: Antoine Pitrou To: python-announce-list@python.org Content-Type: text/plain; charset="UTF-8" Date: Mon, 30 Jan 2012 21:14:44 +0100 Mime-Version: 1.0 X-Mailer: Evolution 2.32.2-2.mga1 Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Tue, 31 Jan 2012 16:00:57 +0100 X-BeenThere: python-announce-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org List-Id: Announcement-only list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Approved: python-announce-list@python.org Newsgroups: comp.lang.python.announce Message-ID: Lines: 78 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328022057 news.xs4all.nl 6955 [2001:888:2000:d::a6]:52061 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python.announce:493 Hello, I'm releasing pathlib 0.4 for Python 3.2 and later. * Download: http://pypi.python.org/pypi/pathlib/ (you can probably use "pip install pathlib" or "easy_install pathlib" instead) * Documentation: http://readthedocs.org/docs/pathlib/en/latest/ * Issue tracker, repository: https://bitbucket.org/pitrou/pathlib/ What is pathlib --------------- pathlib offers a set of classes to handle filesystem paths. It offers the following advantages over using string objects: * No more cumbersome use of os and os.path functions. Everything can be done easily through operators, attribute accesses, and method calls. * Embodies the semantics of different path types. For example, comparing Windows paths ignores casing. * Well-defined semantics, eliminating any warts or ambiguities (forward vs. backward slashes, etc.). Examples -------- Importing the module classes:: >>> from pathlib import * Listing Python source files in a directory:: >>> p = Path('.') >>> [x for x in p if x.ext == '.py'] [PosixPath('test_pathlib.py'), PosixPath('setup.py'), PosixPath('pathlib.py')] Listing subdirectories:: >>> [x for x in p if x.is_dir()] [PosixPath('.hg'), PosixPath('docs'), PosixPath('dist'), PosixPath('__pycache__'), PosixPath('build')] Navigating inside a directory tree:: >>> p = Path('/etc') >>> q = p['init.d/reboot'] >>> q PosixPath('/etc/init.d/reboot') >>> q.resolve() PosixPath('/etc/rc.d/init.d/halt') Querying path properties:: >>> q.exists() True >>> q.is_dir() False >>> q.st_mode 33261 Opening a file:: >>> with q.open() as f: f.readline() ... '#!/bin/bash\n' Regards Antoine Pitrou.