[Python-ideas] PEP: Extended stat_result (First Draft)

Pieter Nagel pieter at nagel.co.za
Mon May 6 14:29:27 CEST 2013


On Mon, 2013-05-06 at 11:30 +0200, Antoine Pitrou wrote:

> I don't really understand the point of a null object here, since
> os.stat() will raise when called on a non-existent patch.

The point is that I am proposing to (optionally) change the behaviour of
os.stat(), so they will *not* raise when the path is non-existent, but
instead will return a null object.

That can be achieved by adding a keyword argument flag like, for
example, null_if_missing, to os.stat() that will select the new
behaviour. The default will be the current behaviour.

This null object will implement exists(), is_file() and the like so that
it returns False exactly as os.path.exists(), os.path.isfile() etc.
would have done, if one had used them instead of os.stat() to
interrogate() the properties of the file.

-- 
Pieter Nagel





More information about the Python-ideas mailing list