I'm trying to figure out why you would create a containing class if you were just going to import it from a file, vs just creating the general classes that you will simply import.
I'm just wondering if the two code examples below are equivilent. If not, what differences would there be?
Using simple "import Creds":
Creds.py:
creds.py:
I'm just wondering if the two code examples below are equivilent. If not, what differences would there be?
Using simple "import Creds":
Creds.py:
import random class Server1: url = "server1.com" username = "username" password = "password" randkey = random.randint(1, 10) class Server2: url = "server2.com" username = "username" password = "password" randkey = random.randint(1, 10)
import Creds print(Creds.Server2.randkey)versus using "from creds import Creds":
creds.py:
import random class Creds: class Server1: url = "server1.com" username = "username" password = "password" randkey = random.randint(1, 10) class Server2: url = "server2.com" username = "username" password = "password" randkey = random.randint(1, 10)
from creds import Creds print(Creds.Server2.randkey)