diff --git a/basic_examples/python_write.py b/basic_examples/python_write.py index e5d08de..68d3575 100644 --- a/basic_examples/python_write.py +++ b/basic_examples/python_write.py @@ -2,7 +2,7 @@ from sys import argv #unpack script, filename = argv -fp = open(filename, "w") -print "Writing to file %r " % fp -fp.write("Hello World") -fp.close() +# A more clean and modern Python 3 to write to file. +with open(filename, "w") as f: + print("Writing to file: ".format(filename)) # As python 3+ + f.write("Hello World")