Thoughts on some stdlib modules

Peter Hansen peter at engcorp.com
Mon Apr 11 10:17:35 EDT 2005


Martin v. Löwis wrote:
> I personally find the notion of "path objects" confusing. Is this a
> real path name on the local system, or merely a potential one? If
> potential, why does it have a .size attribute 

> (what is the size of a non-existing file)? 

Logically (and, I feel, quite intuitively), it's an exception:

 >>> from path import path
 >>> path('testxxx').size
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "c:\python24\lib\ntpath.py", line 229, in getsize
     return os.stat(filename).st_size
OSError: [Errno 2] No such file or directory: u'testxxx'

-Peter



More information about the Python-list mailing list