Mayur Satav
Mayur Satav

Reputation: 1102

what are the Best coding practice for creating python package

I am creating pypi python package and for that i tired many solution avilable in different websites.

  1. First of all I followed this Approach1, in this approach author has created class and functions but when tried this one my package gave me an error that no module and class name is not define
  2. I tired many other Approaches like this one Approach2 in this approach author created only functions without class and __init__.py
  3. and then tried this one also which is very common Approach3

and here is important files structure provided by pypi officials

├── LICENSE
├── README.md
├── example_pkg
│   └── __init__.py
├── setup.py
└── tests

I am ready with my package but after spending whole night finding which one is Best coding practice? and now got confused

so my questions are as follows

  1. what is the use of file __init__.py?
  2. best practice for giving directory, class and functions names so that it will help during importing.because according to these answers some people said import directory name, some said filename followed by class etc..
  3. Can anyone provide me proper steps so that i can follow in upcoming packages also

Upvotes: 2

Views: 1077

Answers (1)

Dustin Ingram
Dustin Ingram

Reputation: 21520

I'd recommend following the Python Packaging Authorities guides and tutorials at https://packaging.python.org.

In addition, the PyPA publishes an example project skeleton that you can use as a starting point: https://github.com/pypa/sampleproject/

Upvotes: 2

Related Questions