[Python-ideas] Dunder method to make object str-like

Chris Barker chris.barker at noaa.gov
Thu Apr 7 14:59:09 EDT 2016


On Thu, Apr 7, 2016 at 11:48 AM, Terry Reedy <tjreedy at udel.edu> wrote:

> To me, the default proposal to expand the domain of open and other path
> functions is to call str on the path arg, either always or as needed. We
> should then ask "why isn't str() good enough"?  Most bad args for open will
> immediately result in a file-not-found exception.  But the os.path
> functions would not.  Do the possible bugs and violation of python
> philosophy out-weigh the simplicity of the proposal?


Thanks -- this is exactly the question at hand. it's gotten a bit caught up
in all the discussion of what to call the magic method, should there be a
top-level function, etc.  but this is the only question on the table that
isn't just bikeshedding.

personally, I think not -- but I"m very close to the fence.

Though no, most calls to open() would not fail -- most calls to open(path,
'r') would but most calls to open(path, 'w') would succeed and produce some
really weird filenames -- but so what?


that's the question -- are these subtle and hard to find bugs we want to
prevent?

-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 at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160407/f75069c9/attachment-0001.html>


More information about the Python-ideas mailing list