Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

What is the benefit of using import X as X? [duplicate]

$
0
0

I know what as keyword does in import statement, we use it to give an object a different name in the module's namespace. It can be its simplified name(like np for numpy) or completely different name that avoids clashes with other names present in the module.

But, I've seen many libraries that give the exact same name to the object like:

from package.module import FOO as FOO

Why? Is it different from: from package.module import FOO ?

couple of examples:

FastAPI:

from .applications import FastAPI as FastAPI

SQLAlchemy:

from .engine import AdaptedConnection as AdaptedConnection

and so many others.


Viewing all articles
Browse latest Browse all 23131

Trending Articles