DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Run Python Script within a Module


Run a script in Functional Python Programming: python -m Chapter_8.ch08_ex1.

Demo

take pymod
mkdir -p moda modb
touch moda/__init__.py modb/__init__.py
cat << EOF > modb/lib.py
def myadd(a, b):
    return a * 10 + b
EOF
cat << EOF > moda/app.py
from modb.lib import myadd
print(myadd(3, 5))
EOF
python -m moda/app
35


Published

Sep 1, 2017

Last Updated

Sep 1, 2017

Category

Tech

Tags

  • module 4
  • python 136

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor