[Python-Dev] PEP 246, redux

Phillip J. Eby pje at telecommunity.com
Thu Jan 13 00:06:34 CET 2005


At 03:19 PM 1/12/05 -0700, Steven Bethard wrote:
>On Wed, 12 Jan 2005 16:07:37 -0600, Ian Bicking <ianb at colorstudy.com> wrote:
> > One case occurred to me with the discussion of strings and files, i.e.,
> > adapting from a string to a file.  Let's say an IReadableFile, since
> > files are too ambiguous.
> >
> > Consider the case where we are using a path object, like Jason
> > Orendorff's or py.path.  It seems quite reasonable and unambiguous that
> > a string could be adapted to such a path object.  It also seems quite
> > reasonable and unambiguous that a path object could be adapted to a
> > IReadableFile by opening the file at the given path.
>
>This strikes me as a strange use of adaptation -- I don't see how a
>string can act-as-a path object, or how a path object can act-as-a
>file.

I see the former, but not the latter.  A string certainly can act-as-a path 
object; there are numerous stdlib functions that take a string and then use 
it "as a" path object.  In principle, a future version of Python might take 
path objects for these operations, and automatically adapt strings to them.

But a path can't act as a file; that indeed makes no sense.



More information about the Python-Dev mailing list