Skip to content

Instantly share code, notes, and snippets.

@squarefrog
Created June 17, 2015 13:19
Show Gist options
  • Save squarefrog/04b256891499f42c6473 to your computer and use it in GitHub Desktop.
Save squarefrog/04b256891499f42c6473 to your computer and use it in GitHub Desktop.
Workaround for multiline Alfred input in a Python workflow
'''
Pasting in multiline text, eg:
This is
some text
fails when using the following, Alfred provided starting point.
'''
# Breaks ALL the things..
query = '{query}'
'''
As the query is dynamically replaced it raises an exception as python strings
are not permitted to wrap over multiple lines (unless escaped)
This can be solved however, using a triple quote:
'''
# Oh neat!
query = '''{query}'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment