Filename type (Was: Re: finding file size)

Just just at xs4all.nl
Sat Jan 3 13:27:38 CET 2004


In article <mailman.45.1073125105.12720.python-list at python.org>,
 Gerrit Holl <gerrit at nl.linux.org> wrote:

> I propose to add a "filename" type to Python.
> 
[ ... ]
> A different solution to this problem would be to introduce "filename"
> type to Python, a subclass of str. The "name" attribute of file would be of 
> this
> type. This type would inherit a lot of os.path stuff: getsize becomes
> simpler, more readable, and more object oriented, as do other os.path
> functions. I think the alternatives look a lot more prety:
> 
> OLD                                         NEW
> os.path.realpath(fn)                        fn.realpath()
> os.path.getmtime(fp.name)                   fp.name.getmtime()
> os.path.ismount(os.path.dirname(fp.name))   fp.name.dirname().ismount()
> 
> It's more beatiful, simpler, flatter (#3), practical, obvious, easy.

This has been proposed a few times, and even implemented at least once:

  http://www.jorendorff.com/articles/python/path/

I'm very much in favor of adding such an object, but I don't like Jason 
Orendorff's design all that much. There has been a discussion about it 
in the past:

http://groups.google.com/groups?q=g:thl1422628736d&dq=&hl=en&lr=&ie=UTF-8
&oe=UTF-8&safe=off&selm=mailman.1057651032.22842.python-list%40python.org

Just



More information about the Python-list mailing list