[path-PEP] Path inherits from basestring again

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sat Jul 23 05:35:50 EDT 2005


Hi,

the arguments in the previous thread were convincing enough, so I made the
Path class inherit from str/unicode again.

It still can be found in CVS: /python/nondist/sandbox/path/{path.py,test_path.py}

One thing is still different, though: a Path instance won't compare to a regular
string.

Other minor differences, as requested on python-dev, are:

* size property -> getsize() method.
* atime/mtime/ctime properties -> atime()/mtime()/ctime() methods

* dirname() method -> directory property
* no parent property
* basename() method -> basename property
* no name property

* listdir() method -> children() method
* there is still a listdir() method, but with the semantics of os.listdir
* dirs() method -> subdirs() method
* joinpath() method -> added alias joinwith()
* splitall() method -> parts() method

* Default constructor: Path() == Path(os.curdir)
* staticmethod Path.getcwd() -> Path.cwd()

* bytes() / lines() / text() -> read_file_{bytes,lines,text} methods
* write_{bytes,lines,text} -> write_file_{bytes,lines,text} methods

These may be removed though.

Reinhold



More information about the Python-list mailing list