[Python-3000] format and datetime (original) (raw)
Eric Smith eric+python-dev at trueblade.com
Tue Sep 11 16:21:10 CEST 2007
- Previous message: [Python-3000] __format__ and datetime
- Next message: [Python-3000] [Python-3000-checkins] r58068 - in python/branches/py3k: Doc/library/exceptions.rst Doc/library/socket.rst Doc/whatsnew/2.6.rst Lib/test/test_urllib2net.py Lib/urllib2.py Modules/socketmodule.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Nick Coghlan wrote:
Eric Smith wrote:
Eric Smith wrote:
I have a patch to add format to datetime.time, .date, and .datetime. For non-empty formatspec's, I just pass on to .strftime. For empty formatspec's, it returns str(self).
What's the best way to call str(self)? I'm currently doing: if (PyUnicodeGetSize(format) == 0) return PyObjectCallMethod((PyObject *)self, "str", NULL); Although this works, calling self.str doesn't seem like the right thing to do. PyObjectStr is the C API equivalent of str, but I believe PyObjectUnicode is currently the right call for Py3k [1].
Of course! Thanks for the help, I was trying to over-complicate it.
Eric.
- Previous message: [Python-3000] __format__ and datetime
- Next message: [Python-3000] [Python-3000-checkins] r58068 - in python/branches/py3k: Doc/library/exceptions.rst Doc/library/socket.rst Doc/whatsnew/2.6.rst Lib/test/test_urllib2net.py Lib/urllib2.py Modules/socketmodule.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]