quantifiedcode / python-anti-patterns

An open collection of Python anti-patterns and worst practices.
https://quantifiedcode.github.io/python-anti-patterns
Other
1.71k stars 249 forks source link

Add common abbreviation for sympy to KB #96

Open pylang opened 8 years ago

pylang commented 8 years ago

This issues refers to Use common abbreviations for libraries in the Python Knowledge Base.

Issue

The common abbreviation listed in the knowledge base for Scipy is import scipy as sp.

Although unmentioned, this alias conflicts with the common convention for Sympy: import sympy as sp .

Observations

I have seen statements import scipy as sc in the past. However, I find it is more common to import a submodule from Scipy, which cannot be accessed through aliases in this manner.

In general, it is recommended to import functions from submodule namespaces.

As suggested in the documentation, recommended formats include:

  1. from scipy import integrate
  2. import scipy.io as spio
  3. from scipy.stats import distributions

I don't particularly like these suggestions, but I believe they more accurately reflect common practices than what is currently stated in the knowledge base.

Requests

  1. Can the abbreviation for Sympy be added to the knowledge base?
  2. Can we use an official, recommended convention for Scipy's alias?

References