[Python-Dev] The path module PEP
Ian Bicking
ianb at colorstudy.com
Wed Jan 25 22:05:33 CET 2006
John J Lee wrote:
> On Tue, 24 Jan 2006, Ian Bicking wrote:
> [...]
>
>>Losing .open() would make it much harder for anyone wanting to write,
>>say, a URI library that implements the Path API.
>
> [...]
>
> Why? Could you expand a bit?
>
> What's wrong with urlopen(filesystem_path_instance) ?
My example shows this more clearly I think:
def read_config(path):
text = path.open().read()
... do something ...
If I implement a URI object with an .open() method, then I can use it
with this function, even though read_config() was written with file
paths in mind. But without it that won't work:
def read_config(path):
text = open(path).read()
...
--
Ian Bicking / ianb at colorstudy.com / http://blog.ianbicking.org
More information about the Python-Dev
mailing list