New submission from Jeong-Min Lee <false...@gmail.com>: format(datetime_obj, format_string) return format_string. (when format_string is not empty.)
>>> import datetime >>> d = datetime.datetime.now() >>> format(d) '2009-06-20 23:51:54.243428' >>> format(d, '') '2009-06-20 23:51:54.243428' >>> d datetime.datetime(2009, 6, 20, 23, 51, 54, 243428) >>> '{0}'.format(d) '2009-06-20 23:51:54.243428' >>> '{0:30}'.format(d) # odd '30' >>> format(d, '30') # odd '30' >>> format(str(d), '30') # workaround '2009-06-20 23:51:54.243428 ' >>> '{0!s:30}'.format(d) # workaround '2009-06-20 23:51:54.243428 ' ---------- components: Extension Modules, Library (Lib) messages: 89539 nosy: falsetru severity: normal status: open title: format, str.format don't work well with datetime, date object type: behavior versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6316> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com