7bisso 7bisso - 3 months ago 11
Python Question

How do I dynamically generate a file name in python?

We're working on a python application for MAC OSX that should be pip-installable, and we want to automate the creation of a

file during installation, but the file name must contain the OSX username in order for the application to work, eg.

Q : How do I dynamically generate such a file in python ?


Since you just need the username:

import getpass
user = getpass.getuser()
fname = "com.strange.things." + user + ".more.strange.things"