Created
February 5, 2018 08:34
-
-
Save dalaing/3ebda19719ad3e701df1f10bf7c18363 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def writeFile(filename, contents): | |
with open(filename, "w") as f: | |
f.write(contents) | |
def readFile(filename): | |
contents = "" | |
with open(filename, "r") as f: | |
contents = f.read() | |
return contents | |
def p1(): | |
file = "/tmp/file" | |
writeFile(file, "abcdef") | |
x = readFile(file) | |
print(x) | |
writeFile(file, "ghijkl") | |
y = readFile(file) | |
print (x + y) | |
def p2(): | |
file = "/tmp/file" | |
expr = readFile(file) | |
writeFile(file, "abcdef") | |
x = expr | |
print(x) | |
writeFile(file, "ghijkl") | |
y = expr | |
print (x + y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment