[Python-ideas] Dunder method to make object str-like
Émanuel Barry
vgr255 at live.ca
Thu Apr 7 11:05:45 EDT 2016
More information about the Python-ideas mailing list
Thu Apr 7 11:05:45 EDT 2016
- Previous message (by thread): [Python-ideas] Dunder method to make object str-like
- Next message (by thread): [Python-ideas] Dunder method to make object str-like
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> From: Ethan Furman > Sent: Thursday, April 07, 2016 11:01 AM > To: python-ideas at python.org > Subject: Re: [Python-ideas] Dunder method to make object str-like > > On 04/07/2016 06:46 AM, Émanuel Barry wrote: > > > __index__ is meant to return the same thing as __int__, and I think the > same > > restrictions should apply here > > Do you mean "the same thing" as in both return 'int', or "the same > thing" is in __int__(3.4) == __index__(3.4) ? Because that last one is > False. I badly phrased that, let me try again. In the cases that __index__ is defined (and does not raise), it should return the same thing as __int__. > > Hmmm -- so maybe you are saying that if the results of __str__ and > __tostring__ are the same we're fine, just like if the results of > __int__ and __index__ are the same we're fine? Otherwise an error is > raised. > Pretty much; as above, if __tostring__ (in absence of a better name) is defined and does not raise, it should return the same as __str__. -Emanuel
- Previous message (by thread): [Python-ideas] Dunder method to make object str-like
- Next message (by thread): [Python-ideas] Dunder method to make object str-like
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list