Skip to content

urbanslug/Arithmetic

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

Arithmetic

Just a package to demonstrate proper project stucturing in python.

Project structure:

$ pwd
~/src/python/Arithmetic/arithmetic

$ tree
.
├── arithmetic
│   ├── division
│   │   ├── divide.py
│   │   ├── __init__.py
│   │   ├── __main__.py
│   │   └── __pycache__
│   ├── __init__.py
│   ├── __main__.py
│   ├── multiplication
│   │   ├── __init__.py
│   │   ├── __main__.py
│   │   ├── multiply.py
│   │   └── __pycache__
│   └── tests
│       ├── division
│       │   └── test_divide.py
│       ├── __init__.py
│       ├── __main__.py
│       └── multiplication
│           └── test_multiply.py

Running modules individually.

  • Arithmetic: python -m arithmetic
  • Division: python -m arithmetic.division
  • Multiplication: python -m arithmetic.multiplication
  • Tests: python -m arithmetic.tests

However the following for example fails. How can I make them work and is it necessary?

$ python arithmetic/tests/test_divide.py 
Traceback (most recent call last):
  File "arithmetic/tests/test_divide.py", line 2, in <module>
    import arithmetic.divide as divide
ImportError: No module named 'arithmetic'


$ python arithmetic/tests/test_multiply.py 
Traceback (most recent call last):
  File "arithmetic/tests/test_multiply.py", line 1, in <module>
    import arithmetic.multiply as multiply
ImportError: No module named 'arithmetic'

About

An example project for python project structuring.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages