[Python-ideas] Better stdlib support for Path objects

Antoine Pitrou solipsis at pitrou.net
Tue Oct 7 17:55:38 CEST 2014


On Wed, 8 Oct 2014 02:48:25 +1100
Chris Angelico <rosuav at gmail.com> wrote:
> On Wed, Oct 8, 2014 at 2:39 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> > On Wed, 8 Oct 2014 00:49:12 +1000
> > Nick Coghlan <ncoghlan at gmail.com> wrote:
> >>
> >> Combining this thought with Chris Angelico's reply, I actually wonder
> >> if the index vs int analogy is even more applicable than I first
> >> thought.
> >>
> >> What if the protocol was __text__ with a new text() builtin (or at
> >> least an operator.text() function), and it was advised to only be
> >> implemented by types where they were, at least conceptually, truly
> >> representable as strings?
> >
> > What does "truly representable, at least conceptually" mean?
> > Do HTML trees apply? Configuration files? Command-line arguments?
> >
> 
> I like the comparison with __index__. It's up to the class to decide
> whether it wants to be "truly representable as a string". Command-line
> arguments probably would be, in some canonical form. Config files
> probably not, as they need their structure, but if you want your
> config object to act exactly like a text string, then you define
> __text__.

And what's the use case that would be fulfilled by this exactly?





More information about the Python-ideas mailing list