Reputation: 16730
Google's style guide says, about imports, that modules might be aliased with import xyz as x
when x
is a common abbreviation for xyz
.
What are the standard abbreviations for the most common modules?
I'm here looking for a list exhaustive as possible, including modules from the standard library, as well as third-party niche packages that are frequently used in their respective fields.
For instance, numpy
is always imported as np
, and tkinter
, when hopefully not imported with from module import *
, is generally imported as tk
.
Upvotes: 6
Views: 1846
Reputation: 16730
Here are the names I see most of the time for the modules I frequently use. This list is not meant to become an absolute reference, but I hope it will help provide some guidelines. Please feel free to complete it, or to change whatever you think needs to be changed.
The import statements follow the conventions established by Google's Python style guide, namely:
import x
for importing packages and modules.from x import y
where x
is the package prefix and y
is the module name with no prefix.x import y as z
if two modules named y
are to be imported or if y
is an inconveniently long name.import y as z
only when z
is a standard abbreviation (e.g., np
for numpy
).MODULE ALIAS IMPORT STATEMENT
datetime dt import datetime as dt
matplotlib.pyplot plt from matplotlib import pyplot as plt
multiprocessing mp import multiprocessing as mp
numpy np import numpy as np
pandas pd import pandas as pd
seaborn sns import seaborn as sns
tensorflow tf import tensorflow as tf
tkinter tk import tkinter as tk
Upvotes: 3