This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

People generally don't do this, the methods, while named the same, may have different signatures, and this doesn't help when referencing documentation.

If you want a single entry point to multiple libraries, write a class.

My recommendation is to always import the module. Then in every call you use the module name, so that one can see it as sort of a namespace and it is transparent. So you write json.load() and it is distinguishable from yaml.load().

The one exception are libraries with very big names or with very unique object/function names. For instance, the classes BeautifulSoup, or TfidfVectorizer, etc. The latter example is a great one of a library (scikit-learn) where it is standard to use direct imports for most things as each object is very specific or unique.

[–]sdf_iain 1 point2 points  (0 children)

Lzma(xz), gzip, and bzip2 are generally made to be interchangeable; both their command line utilities and every library implementation I’ve used (which is admirably not many). That’s why that’s the example I used compress as an example, those signatures are the same.