[Python] Global Variable from a different file Python

Discussão em 'Python' iniciado por Stack, Fevereiro 1, 2025.

  1. Stack

    Stack Membro Participativo

    So I have two different files somewhat like this:

    file1.py

    from file2 import *
    foo = "bar"
    test = SomeClass()


    file2.py

    class SomeClass :
    def __init__ (self):
    global foo
    print foo


    However I cannot seem to get file2 to recognize variables from file1 even though its imported into file1 already. It would be extremely helpful if this is possible in some way.

    Continue reading...

Compartilhe esta Página