On Sat, Apr 6, 2013 at 7:29 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > For some definition of "easily". > > if implementation == "CPython": > if version < "3.3": > if sys.maxunicode exists: > use it to decide whether this is a wide or narrow build > if a wide build: return 4 > else: return 2 > else: > ??? > elif version == "3.3": > scan the string, in some efficient or inefficient way > return 1, 2, 4 depending on the largest character you find > else: > ??? > else: > ???
None of which goes away if a char width function is added to 3.4 and you still want to support earlier versions as this does. It just adds another "if". -- http://mail.python.org/mailman/listinfo/python-list