Possible Duplicate:
Split string into a list in Python
I have a string with a lot of part-strings
>>> s = 'str1, str2, str3, str4'
now I have a function like following
>>> def f(*args):
print(args)
what I need, is to split my string into multiple strings, so that my function prints something like this
>>> f(s)
('str1', 'str2', 'str3', 'str4')
Has someone an idea, how I can perform this?
- edit: I did not searched a function to split a string into an array of Strings.
This is what i searched for.
>>> s = s.split(', ')
>>> f(*s)
('str1', 'str2', 'str3', 'str4')
def f(*args): print(args) if __name__ == '__main__': s = 'str1, str2, str3, str4' f(*(s.split(', ')))def dirEntries(fileList, subdir=False, *args): '''Example usage: fileList = dirEntries(r'H:\TEMP', False, 'txt', 'py') Only files with 'txt' and 'py' extensions will be added to the list. Example usage: fileList = dirEntries(r'H:\TEMP', True)'''