I have a fun little script that i would like to make a copy of itself in a random directory - then run that copy of itself.
I know how to run files with (hacky):
You can get list of all dirs and subdirs, and shuffle it in random as follows:
import os import random all_dirs = [x for x in os.walk('/tmp')] random.shuffle(all_dirs) for a_dir in all_dirs: print(a_dir) # do something witch each directory, e.g. copy some file there.