I have a number of variables which are set and later in my code I want to use these variables together as one single variable with a . separation.
For example
Release=1
Build=2
ServicePack=3
Hotfix=4
Directory=Release.Build.ServicePack.Hotfix
I understand that the above line will not work but I’m not sure how to join the variables together when declaring the last one.
In my example I would like the Directory variable to equal '1.2.3.4'.
Th end goal here is to use os.path to create a directory based on the value of Directory. Given this would a better alternative to use os.path.join and pass in the individual variables instead of a single one?
Turn each variable into a string. Join them together with a ‘.’ in between.
will work fine, resulting in
If I were you, I’d either use all caps for those variables, meaning they’re constants, or all lower case, as specified in PEP 8.