Skip to content

Instantly share code, notes, and snippets.

@ntijoh-daniel-berg
Created March 10, 2016 09:27
Show Gist options
  • Save ntijoh-daniel-berg/813803876ae6923d21a9 to your computer and use it in GitHub Desktop.
Save ntijoh-daniel-berg/813803876ae6923d21a9 to your computer and use it in GitHub Desktop.
import glob
def list_files_in_folder():
files_and_folders = glob.glob('*.*')
for thing in files_and_folders:
print(thing)
def ask_for_file_name():
file = raw_input('Enter name of file to view ')
return file
def print_file(filename):
try:
with open(filename) as grillkorv:
for line in grillkorv:
print line
except IOError, e:
print("can not find file ({0})".format(filename))
print('These files exist:')
list_files_in_folder()
filename = ask_for_file_name()
print_file(filename)
list_files_in_folder()
file_to_print = ask_for_file_name()
print_file(filename=file_to_print)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment