Python

RELATED: SETUP > Dev Environment > Pythonarrow-up-right |

Books

Google Drive > Books > Dev Languages > Python - https://drive.google.com/drive/folders/0B-bIAh9FWNPda0ZfWHpScFR3SWs?resourcekey=0-G5fNrsHYYOAIzXp-ksAIpQ&usp=sharingarrow-up-right

Create & Delete virtual environment

Go to: SETUP > Dev Environments > Python - Highlights - virtual environment...

Capture pip packages

$ pip freeze > requirements.txt      # export
$ pip install -r requirements.txt    # import

Python conventions

DEVELOP

Create Django project

Source: AWS - Deploying a Django application to Elastic Beanstalkarrow-up-right

Create a scaffold Django project:

API

Go to DEVELOP > API

Useful Notes 🚧

  • debugger -

  • dunder methods - special methods to perform basic object operations also known as "dunder" methods; double underscore before and after.

Cheat sheet (ref-1)

  • A single statement can span across multiple lines by enclosing part of the statement in a bracketed pair—parentheses (), square brackets [], curly braces {}, triple-quoted string literals """_""", or end with a backslash \ (ref-1)

  • Features to remember: List unpacking; (ref-1)

  • import <module> vs from <module> import * - former: loads & become a variable to be used (e.g., load mod1; mod1.func1()); the latter: copy the function only and use it without going through the module again (e.g. from mod1 import func1; func1())

  • Variables prefixed with a single underscore (e.g., _X) are not copied out when a client imports a module’s names with a from * statement; but visible via the import <module-name> (ref-1)

  • AVOID names that have two leading and trailing underscores (__X__) are system-defined names that have special meaning to the interpreter.

  • Documentation strings (docstrings for short) are ignored but are saved and displayed by tools

DEPLOY

Packaging

Online IDE

Open source libraries

  • Game programming and multimedia with pygame, cgkit, pyglet, PySoy, Panda3D, and others

  • Serial port communication on Windows, Linux, and more with the PySerial ex- tension

  • Image processing with PIL and its newer Pillow fork, PyOpenGL, Blender, Maya, and more

  • Robot control programming with the PyRo toolkit

  • Natural language analysis with the NLTK package

  • Instrumentation on the Raspberry Pi and Arduino boards

  • Finance: yfinance (pip install yfinance)

  • Mobile computing with ports of Python to the Google Android and Apple iOS platforms

  • Excel spreadsheet function and macro programming with the PyXLL or DataNi- tro add-ins

  • Media file content and metadata tag processing with PyMedia, ID3, PIL/Pillow, and more

  • Artificial intelligence with the PyBrain neural net library and the Milk machine learning toolkit

  • Expert system programming with PyCLIPS, Pyke, Pyrolog, and pyDatalog

  • Network monitoring with zenoss, written in and customized with Python

  • Python-scripted design and modeling with PythonCAD, PythonOCC, FreeCAD, and others

  • Document processing and generation with ReportLab, Sphinx, Cheetah, PyPDF, and so on

  • Data visualization with Mayavi, matplotlib, VTK, VPython, and more

  • XML parsing with the xml library package, the xmlrpclib module, and third-party extensions

  • JSON and CSV file processing with the json and csv modules

  • Data mining with the Orange framework, the Pattern bundle, Scrapy, and custom code

How-to

How-to: install Python Packages from a local folder

Reference: https://www.activestate.com/resources/quick-reads/how-to-manually-install-python-packages/arrow-up-right

chevron-rightExample - the Amazon awsiotsdkhashtag
  • Git clone the repo: https://github.com/aws/aws-iot-device-sdk-python-v2

  • The code folder is aws-iot-device-sdk-python-v2/awsiot

  • The installation instructions are defined in the setup.py:

  • To install the package

References

Last updated