'Python drama with variable

in python I have this set of variable

variable.py

#--------------Project 1--------------#
ip_server = '10.10.55.98'
username = 'user_1'
distro = 'debian'

#--------------Project 2--------------#
ip_server = '10.10.55.96'
username = 'user_2'
distro = 'opensuse'

#--------------Project 3--------------#
ip_server = '10.10.55.95'
username = 'user_3'
distro = 'ubuntu'

In the script main.py I just want to import variable of Project 2, how to this?

main.py

from variable import *

ho_to_import_variable_of_project2?


thanks to all for answers anche time to dedicate my question



Solution 1:[1]

Create a list and dictionary for each project like below:

variable.py

project1 = [{'ip_server' :'10.10.55.98', 'username':'user_1', 'distro' : 'debian'}]
project2 = [{'ip_server' :'10.10.55.95', 'username':'user_2', 'distro' : 'opensuse'}]
project3 = [{'ip_server' :'10.10.55.96', 'username':'user_3', 'distro' : 'ubuntu'}]

And in main.py

from variable import project1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1