The following function should be immune to race conditions and doesn't use mktemp.
def templink(destpath): """Create a hard link to the given file with a unique name. Returns the name of the link.""" pid = os.getpid() i = 1 while True: linkpath = "%s-%s-%s" % (destpath, pid, i) try: os.link(destpath, linkpath) except FileExistsError: i += 1 else: break return linkpath -- Greg -- https://mail.python.org/mailman/listinfo/python-list