[Python-ideas] PEP 428 - object-oriented filesystem paths
Ethan Furman
ethan at stoneleaf.us
Sun Oct 14 21:16:28 CEST 2012
Antoine Pitrou wrote:
> On Sun, 14 Oct 2012 08:48:53 -0700
> Ethan Furman <ethan at stoneleaf.us> wrote:
>
>> What behavior can I expect with your Path implementation when I try to
>> iterate over
>>
>> /usr/home/ethanf/some_table.dbf
>>
>>>> p = Path('setup.py')
>>>> list(p)
>>>>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "./pathlib.py", line 1176, in __iter__
> for name in self._accessor.listdir(self):
> File "./pathlib.py", line 455, in wrapped
> return strfunc(str(pathobj), *args)
> NotADirectoryError: [Errno 20] Not a directory: 'setup.py'
>
Certainly reasonable, and the same behavior I would expect of, e.g.,
p.children(). I guess it just feels too magical to me.
-1 for built-in iteration.
+1 for a .children() (or other) method.
~Ethan~
More information about the Python-ideas
mailing list