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

INADA Naoki songofacandy at gmail.com
Fri Apr 8 09:25:50 EDT 2016


>
>
> We have abstract base classes for such tests, but there's nothing
> which would define "string-like" as ABC. Before trying to define
> a test via a special method, I think it's better to define what
> exactly you mean by "string-like".
>
> Something along the lines of numbers.Number, but for strings.
>
> To make an object string-like, you then test for the ABC and
> then call .__str__() to get the string representation as string.
>
>
Does ABC is easy to use from C?
There should be easy way to (1) define "string-like" class in C and (2) use
"string-like" object from C.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160408/53a20a2b/attachment.html>


More information about the Python-ideas mailing list