Skip to content

Instantly share code, notes, and snippets.

@sherbang
Created June 7, 2017 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sherbang/e395c6b3100097de52a89849f61c92ec to your computer and use it in GitHub Desktop.
Save sherbang/e395c6b3100097de52a89849f61c92ec to your computer and use it in GitHub Desktop.
def safename(filename):
'Convert a string to a safe filename'
keepcharacters = (' ','.','_')
return "".join(c for c in filename if c.isalnum() or c in keepcharacters).rstrip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment