Skip to content

Instantly share code, notes, and snippets.

@bwarren2
Created December 15, 2014 05:01
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 bwarren2/d9be188ebb93cdc06daf to your computer and use it in GitHub Desktop.
Save bwarren2/d9be188ebb93cdc06daf to your computer and use it in GitHub Desktop.
ben@Watt:~$ python
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> with open('foobar.txt', 'r') as f:
... data = f.read()
...
>>> data
'\n\n# I can totally write C, and just have elected not to here! (Not really.)\n'
>>> with open('foobar.txt', 'w') as f:
... f.write('#Definitely a copyright notice')
... f.write(data)
...
>>> with open('foobar.txt', 'r') as f:
... contents = f.read()
...
>>> contents
'#Definitely a copyright notice\n\n# I can totally write C, and just have elected not to here! (Not really.)\n'
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment