Filename type (Was: Re: finding file size)
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
> 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:
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:
More information about the Python-list