Re: Is it possible to get the erroneous variable when getting a NameError exception?

2009-12-26 Thread Michael Fötsch
Stephen Hansen wrote: Dotan Barak wrote: ... eval("my_number < 10", {"__builtins__":None}, {}) Hm, is this true, though? Is there anything subtle or dangerous possible here? He's using eval-- so no statements, its only an expression. He's passing in a 'global

Re: flatten a list of list

2009-08-16 Thread Michael Fötsch
Terry wrote: Is there a simple way (the pythonic way) to flatten a list of list? This is probably the shortest it can get: sum(list_of_lists, []) Kind Regards, M.F. -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode() vs. s.decode()

2009-08-08 Thread Michael Fötsch
Michael Ströder wrote: > >>> timeit.Timer("unicode('äöüÄÖÜß','utf-8')").timeit(1000) > 17.23644495010376 > >>> timeit.Timer("'äöüÄÖÜß'.decode('utf8')").timeit(1000) > 72.087096929550171 > > That is significant! So the winner is: > > unicode('äöüÄÖÜß','utf-8') Which proves that benchmark r