pyknight202
pyknight202

Reputation: 1487

How to import functions with the same name from different modules?

For example, something like this:

import module.main
import module2.main

module.main()
module2.main()

Would it be possible to import specific functions from different modules, but be able to differentiate them if they have the same name by a syntax such as the one above?

Upvotes: 1

Views: 527

Answers (1)

Barmar
Barmar

Reputation: 780871

Use as to assign a new name:

import module.main as main1
import module2.main as main2

main1() # module.main()
main2() # module2.main()

Upvotes: 3

Related Questions