I'm working on a function that generates a random file and then prints it; currently I have the following code :
import os
import random
def randomfile(path):
files = os.listdir(path)
index = random.randrange(0, len(files))
return files[index]
pick = randomfile("~/me/Desktop/files")
os.system("cat",pick) # Here i want to execute cat with the random file generated
Basically, I just want to print the generated file, how can I pass it to os.system ?