There's got to be an easy way to do this

Skip Montanaro skip at pobox.com
Thu Jul 5 15:02:09 EDT 2001


Ooh!  A performance thread!  This function is about one-third better than
str_join.

    def str_join2(iters):
	has = {0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1}.has_key
	for i in iters:
	    "".join([x for x in '(123)/456-7890' if has(x)])

:-)

-- 
Skip Montanaro (skip at pobox.com)
(847)971-7098




More information about the Python-list mailing list