Skip to content

Instantly share code, notes, and snippets.

@jfialkoff
Created August 26, 2013 14:21
Show Gist options
  • Save jfialkoff/6341930 to your computer and use it in GitHub Desktop.
Save jfialkoff/6341930 to your computer and use it in GitHub Desktop.
Some useful string tools
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