BlackVegetable
BlackVegetable

Reputation: 13054

Module and Parameter with the same name

I have seen a question on SO about having a Parameter and a Function with the same name, and how to deal with that, but I haven't found one that deals with having a parameter and a module with the same name.

I would prefer to avoid using the from x import * importing method in favor of import x. However, this leads me to the situation where I have a parameter to a function named x, which is the same as the module name x. What are the cleanest ways to get around this?

Upvotes: 1

Views: 66

Answers (1)

Alex
Alex

Reputation: 44385

Rename the imported module to something else, so it lives in a different namespace:

import x as y

then you can use the imported object with a differently chosen name.

Upvotes: 4

Related Questions