Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I expose a function in a Python module?

I wrote a module that consists of a single function. I'd like to be able to use it something like how tqdm works:

>>> from tqdm import tqdm
>>> tqdm
<function tqdm.tqdm>

However I can't figure out how to set things up this way. Here's what I have:

>>> from missingno import missingno
>>> missingno
<module 'missingno.missingno' from '[...]'>
>>> missingno.missingno
<function missingno.missingno.missingno>

I'm sure this has been asked countless times before, but I'm unsure of how packaging works and can't find an answer to this particular riddle.

Here is the repository: https://github.com/ResidentMario/missingno.

like image 508
Aleksey Bilogur Avatar asked Mar 28 '16 02:03

Aleksey Bilogur


1 Answers

After looking at pandas-profiling I've figured it out. Add the following line to __init__.py():

from .missingno import missingno

like image 59
Aleksey Bilogur Avatar answered Sep 30 '22 14:09

Aleksey Bilogur