Skip to content

Instantly share code, notes, and snippets.

@ColtonPhillips
Last active August 29, 2015 14:05
Show Gist options
  • Save ColtonPhillips/2e74c870a0be91d4c60f to your computer and use it in GitHub Desktop.
Save ColtonPhillips/2e74c870a0be91d4c60f to your computer and use it in GitHub Desktop.
Creates a pythonic list of strings from a simple text file, in attempts to save time for certain tasks.
import pprint
pp = pprint.PrettyPrinter(indent=4)
with open('test.txt', 'r') as listFile:
lines = listFile.read().split("\n")
with open('out.py', 'a') as outFile:
outFile.write(pprint.pformat(lines))
['(a)',
'(()',
'I love it!',
'Hello blurb',
'(""")',
'\'"""\'',
'""',
'Noice"\'""\'',
'Colton said "Hello!" and then "fuck..."',
'""" """ """ """ """',
'""" """ """ """',
'""" """ """',
'""" """',
'"""',
'""',
'"""',
'""""',
'"""""',
'""""""',
'"""""""',
'""""""""',
'"""""""""',
'"""" """""',
'']
(a)
(()
I love it!
Hello blurb
(""")
'"""'
""
Noice"'""'
Colton said "Hello!" and then "fuck..."
""" """ """ """ """
""" """ """ """
""" """ """
""" """
"""
""
"""
""""
"""""
""""""
"""""""
""""""""
"""""""""
"""" """""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment