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

Oleg Broytman phd at phdru.name
Mon May 6 18:58:01 CEST 2013


On Mon, May 06, 2013 at 02:29:27PM +0200, Pieter Nagel <pieter at nagel.co.za> wrote:
> 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.

   I don't like the idea of changing os.stat() behaviour. If you want to
have a different type of return value use a different function. Call it
os.stat_ex() or something.

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.



More information about the Python-ideas mailing list