[Python] what does the __file__ variable mean/do?

Discussão em 'Python' iniciado por Stack, Abril 17, 2025.

  1. Stack

    Stack Membro Participativo

    import os

    A = os.path.join(os.path.dirname(__file__), '..')

    B = os.path.dirname(os.path.realpath(__file__))

    C = os.path.abspath(os.path.dirname(__file__))


    I usually just hard-wire these with the actual path. But there is a reason for these statements that determine path at runtime, and I would really like to understand the os.path module so that I can start using it.

    Continue reading...

Compartilhe esta Página