(original) (raw)
On Thu, Apr 7, 2016 at 11:44 AM, Nathaniel Smith <njs@pobox.com> wrote:
No, \_\_index\_\_ is the protocol for "do a safe coerce to integer". The name is misleading, but its use in non-indexing contexts is well established. E.g.
" ab" \* obj
will return a string with obj.\_\_index\_\_() repetitions.
A good argument for Chris A's proposal over on python-ideas to have a dunder method for "coerce to a lossless string", that could be used for Path, but also for who knows what else?
As I see it , exactly the same as the \_\_fspath\_\_ idea, except that we'd use a name that made it clear you might want to use it for other things (and str would grow that method...)
-CHB
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov