Skip to content
Advertisement

How to import objects from another module as a list

in moduleA.py:

A = 1
B = 2
C = 3
D = 4

in moduleB.py, how can I achieve:

from moduleA import (A, B, C, D) as nums

for x in nums:
    print(x)

Advertisement

Answer

You can’t do this the way you are trying to. You will need to find a different solution to your original problem.

Advertisement