Issue
I am trying to define a variable list var_list
which includes hundreds of variables. So I want to do something similar as SAS
to put this definition in an external code instead of the main code. Is there anyway to do that?
For example save the following code in another file called def_var.py
var_list= ['date_of_birth_year_month'
,'zip5'
,'zip4'
,'state_province'
,'city'
,'zip5_ip'
,'zip4_ip'
,'create_user'
,'create_dt'
,'update_user'
,'update_dt'
,'resp_ST'
,'resp_HomeTheater'
,'resp_Headphone']
Solution
Take a look at the import statement.
You can save your variables in def_var.py
as:
var_list= ['date_of_birth_year_month'
,'zip5'
,'zip4'
,'state_province'
,'city'
,'zip5_ip'
,'zip4_ip'
,'create_user'
,'create_dt'
,'update_user'
,'update_dt'
,'resp_ST'
,'resp_HomeTheater'
,'resp_Headphone']
And import it in your main.py
:
from def_var import var_list
# now you can work with your list
print(var_list[1])
Output:
zip5
Answered By - Nils
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.