[Python] Export module components in Python

Discussão em 'Python' iniciado por Stack, Junho 13, 2025.

  1. Stack

    Stack Membro Participativo

    In Julia, it is possible to export a function (or a variable, struct, etc.) of a module, after which it can be called in another script without the namespace (once it has been imported). For example:

    # helpers.jl
    module helpers

    function ordinary_function()
    # bla bla bla
    end

    function exported_function()
    # bla bla bla
    end

    export exported_function()
    end


    # main.jl
    include("helpers.jl")
    using .helpers

    # we have to call the non-exported function with namespace
    helpers.ordinary_function()

    # but we can call the exported function without namespace
    exported_function()


    In Python, is there something I can do within the module, so that when the module is imported, the "exported" components can be called directly?

    Continue reading...

Compartilhe esta Página