Created
August 26, 2013 14:21
-
-
Save jfialkoff/6341930 to your computer and use it in GitHub Desktop.
Some useful string tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def strjoin(*args, **kwargs): | |
""" Concatenates the arguments, ignoring any arguments that are empty or | |
None. | |
""" | |
delim = kwargs.get('delim', '\n') | |
res = '' | |
first = True | |
for arg in args: | |
if arg: | |
if not first: | |
res += delim | |
first = False | |
res += arg | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment