-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex15.py
More file actions
27 lines (20 loc) · 726 Bytes
/
Copy pathex15.py
File metadata and controls
27 lines (20 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Imports the 'argument variable' from the sys package
from sys import argv
# Assigns or "unpacks" the content of 'argv' to variables
script, filename = argv
# Returns a file object and assigns it to the txt variable
txt = open(filename)
# Prints out the name of the file passed to the filename variable
print "Here is your file %r:" % filename
# Prints out the contents of the txt variable
print txt.read()
txt.close()
# Prints a simple string
print "Type the filename again:"
# Stores user input in file_again
file_again = raw_input("> ")
# Creates a file object of the file passed to file_again by the user
txt_again = open(file_again)
# Prints out the contents of txt_again
print txt_again.read()
txt_again.close()