forked from benda/packagehowto
multiple modules
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
"""
|
||||
# Numerix
|
||||
|
||||
Fancy numerics made easy.
|
||||
"""
|
||||
|
||||
# Functions defined directly in __init__.py can be imported directly
|
||||
# from the package (e.g. from numerix import add_four):
|
||||
def add_four(x):
|
||||
"""Add four to a number.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
x: int or float
|
||||
A number.
|
||||
|
||||
Returns
|
||||
-------
|
||||
y: int or float
|
||||
`x` plus 4.
|
||||
"""
|
||||
return x + 4
|
||||
|
||||
|
||||
# Functions from the modules of the package can be imported into the
|
||||
# namespace of the package:
|
||||
from .addition import add_two
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
from .numbers import one
|
||||
|
||||
|
||||
def __add_secret(x):
|
||||
return x + 7
|
||||
|
||||
|
||||
def add_two(x):
|
||||
return x + 2
|
||||
|
||||
|
||||
def one_plus_two():
|
||||
return add_two(one())
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
from .addition import add_two
|
||||
|
||||
|
||||
def one():
|
||||
return 1
|
||||
|
||||
|
||||
def random():
|
||||
return 4 # this number was obtained from a fair die
|
||||
def three():
|
||||
return add_two(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user