- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the convention for structuring Python modules?
Here is a sample project that shows a very good way to structure your projects: https://github.com/kennethreitz/samplemod. The project is about creating the "sample" module. The directory structure looks as follows:
README.rst LICENSE setup.py requirements.txt sample/__init__.py sample/core.py sample/helpers.py docs/conf.py docs/index.rst tests/test_basic.py tests/test_advanced.py
The README.rst file: This file is for giving a brief description of the module, how to set it up, how to use it, etc.
LICENSE: Contains license text and any copyright claims.
setup.py: It is Python's answer to a multi-platform installer and makes file. If you’re familiar with command-line installations, then make && make install translates to python setup.py build && python setup.py install. So it is used to build your project on the user machine.
requirements.txt: A Pip requirements file should specify the dependencies required to contribute to the project: testing, building, and generating documentation. If your project has no development dependencies, or you prefer development environment setup via setup.py, this file is unnecessary.
docs/: This directory contains the documentation for your project.
tests/: All your tests should reside in this directory. Initially, you'll have a single test file. As they start to grow, you can structure your tests like your module directory.
sample/: This directory contains your actual module code. If your module consists of only a single file, you can place it directly in the root of your repository as sample.py. Your library does not belong in an ambiguous src or python subdirectory. This will contain an __init__.py file if you want this module to reside within a package.
- What are Python modules for date manipulation?
- Structuring Python Programs
- What are common practices for modifying Python modules?
- What are the modules required for CGI programming in Python?
- What are the modules available in Python for converting PDF to text?
- Is there a naming convention for tables in MySQL?
- What are the best practices to organize Python modules?
- What is the most compatible way to install python modules on a Mac?
- What is the role of file organization modules for typical file system software(DBMS)?
- According to the New Cartesian Sign Convention" for mirrors
- What are the differences between json and simplejson Python modules?
- Can we iteratively import python modules inside a for loop?
- How can I import modules for a Python Azure Function?
- What are the most useful Python modules from the standard library?