0
user = 'ti'
user = 'dy'

import sys

if user=='ti':
    sys.path.append(r'C:\Users\kie\OneDrive - AUA\TO\Space Modeling\Demand Tool')

There are two users in one script. To constantly change the path directories is tedious. What kind of if or else statements can I use so that the paths can easily change from one user to the other instead of manual input?

martineau
  • 119,623
  • 25
  • 170
  • 301
Pear
  • 1
  • 3
  • 2
    How about a `dict`, whose keys are usernames, and whose values are the corresponding paths? – Random Davis Feb 01 '22 at 21:04
  • For future reference: You can use a limited version of markdown to format your questions and answers quite nicely. [Here's some formatting help](https://stackoverflow.com/help/formatting). – martineau Feb 01 '22 at 21:07
  • @RandomDavis could you give an example on how I would incorporate it? – Pear Feb 01 '22 at 21:08
  • @Pear `user_path = {'ti': r'C:\Users\BlahBlah', 'us': 'C:\Something\Whatever'}` and then just `sys.path.append(user_path['ti'])` (after checking `if username in user_path`). – Random Davis Feb 01 '22 at 21:41

0 Answers0