On Thu, 2009-02-26 at 21:29 +0000, m...@pixar.com wrote: > I have some strings that look like function calls, e.g. > > "junkpkg.f1" > "junkpkg.f1()" > "junkpkg.f1('aaa')" > "junkpkg.f1('aaa','bbb')" > "junkpkg.f1('aaa','bbb','ccc')" > "junkpkg.f1('aaa','with,comma')" > > and I need to split them into the function name and list of parms, > e.g. > > "junkpkg.f1", [] > "junkpkg.f1", [] > "junkpkg.f1", ['aaa'] > "junkpkg.f1", ['aaa','bbb'] > "junkpkg.f1", ['aaa','bbb','ccc'] > "junkpkg.f1", ['aaa','with,comma'] >
quick and dirty for s in string_list: if "(" in s and s[-1] == ")": parts = s.split("(") fn, args = s[0],s[1][:-1].split(",") Tim Wintle -- http://mail.python.org/mailman/listinfo/python-list