[Python] Should I use `import os.path` or `import os`?

Discussão em 'Python' iniciado por Stack, Julho 18, 2025.

  1. Stack

    Stack Membro Participativo

    According to the official documentation, os.path is a module. Thus, what is the preferred way of importing it?

    Should I always import it explicitly?

    import os.path


    Or is importing os enough?

    import os


    I know importing os works (as of Python 2.6), but I want to know if there is any official recommendation about this issue.

    Continue reading...

Compartilhe esta Página