As it was already mentioned, the leading underscore indicates a private/internal variable, which is just a convention in Python; you are still able to import and use it.
What I wanted to add is that I usually recommend against renaming import in projects unless you are building a reusable package or it is a well-established import rename, like import pandas as pd
.
Motivation is the following:
- Most modern IDEs will add imports automatically and if you work on the project together with somebody who will rename imports you will end up with different import styles
- It makes debugging and reading code harder. When somebody sees something like
logging.getLogger(__name__)
he expects logging
to be standard library logging. But once you start using import renames, there can be import my_custom_logging as logging
at the top. And when you or anybody else is reading the code he needs to look at the imports, which is very inconvenient.
- Depending on what you import and rename, the IDE's refactoring functionality will probably behave unexpectedly.
- This will force you to think about naming twice. As we already know naming is one of the hardest things in software development, thinking about naming from the usage perspective will results in better naming for modules, classes, functions, variables.