Nick Coghlan wrote: > Guido van Rossum wrote: >> For data types whose output uses only ASCII, would it be acceptable if >> they always returned an 8-bit string and left it up to the caller to >> convert it to Unicode? This would apply to all numeric types. (The >> date/time types have a strftime() style API which means the user must >> be able to specifiy Unicode.) > > To elaborate on this a bit (and handwaving a lot of important details > out of the way) do you mean something like the following for the builtin > format?: > > def format(obj, fmt_spec=None): > if fmt_spec is None: fmt_spec='' > result = obj.__format__(fmt_spec) > if isinstance(fmt_spec, unicode): > if isinstance(result, str): > result = unicode(result) > return result
That's the approach I'm taking. The builtin format is the only caller of __format__ that I know of, so it's the only place this would need to be done. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com