0

I am trying to implement a switch at the beginning of my code, in order to change the working directory based on who's running the code. In Stata, this exists and looks like the following:

if "`c(username)'" == "albert" { 
    local PATH "/home/albert/Dropbox/Project1"
} 
else if "`c(username)'" == "charlene" {
    local PATH "C:/Users/charlene/Documents/Dropbox/Project1"
}

I am just missing the "user" part in python. Does anyone knows if that even exists ?

Ismael Padilla
  • 5,246
  • 4
  • 23
  • 35
krasnapolsky
  • 347
  • 1
  • 16

1 Answers1

1

Would the getpass.getuser() function do the trick?

Jiří Baum
  • 6,697
  • 2
  • 17
  • 17