Eric Smith wrote:
> Eric Smith wrote:
>> I have a patch to add __format__ to datetime.time, .date, and .datetime. 
>>   For non-empty format_spec's, I just pass on to .strftime.  For empty 
>> format_spec's, it returns str(self).
> 
> What's the best way to call str(self)?
> 
> I'm currently doing:
>      if (PyUnicode_GetSize(format) == 0)
>         return PyObject_CallMethod((PyObject *)self, "__str__", NULL);
> 
> Although this works, calling self.__str__ doesn't seem like the right 
> thing to do.

PyObject_Str is the C API equivalent of str, but I believe 
PyObject_Unicode is currently the right call for Py3k [1].

Cheers,
Nick.

[1] http://docs.python.org/api/object.html

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to