Notes on Python Language

Notes on Python Language

Python Enhancement Proposal

Notes on the fundamental of Python Language , relevant references, and cool things around it.

eSumit@Sumits-MacBook-Pro:~$ pyenv doctor
Cloning /Users/eSumit/.pyenv/plugins/pyenv-doctor/bin/.....
Installing python-pyenv-doctor...
python-build: use readline from homebrew
Installed python-pyenv-doctor to /var/folders/kr/bq8kqm_54l13knm864fxk78m0000gn/T/pyenv-doctor.20180111002154.5923/prefix

Congratulations! You are ready to build pythons!

Python Fundamentals :

Python is portable in different OS

Python developed  by Guido Van Rossum in Netherlands (1986)

Multiple Implementation of Pythin e.g. CPython , JPython

Two Version : Python 2 (2.6. , 2.7)(started since 2004) and Python 3 (3.0, 3.1,3.2,3.3,3.4..3.7) (started since 2008)

Indentation (four spaces) must match that is like to use opening and closing brackets in other language, Never mix spaces and tabs

Check Python Enhancement Proposals

Python strongly typed language, and dynamic type language

Python comes with standard problems, to use type import math

Current version of Python : 3.6.4

dir(__builtins__) gives all builtin functions used in python e.g. max(4,2,1,5,8) give 8 as output

None when no value available to a variable

bool(0) is false rest of  the true, only bool(“”) empty string is false.

if expr:

(four spaces)    print (“expr is True”);

else :

(four spaces)  print (“expr i sFalse”);

Collections : str,list,dict,tuple,range,set

Multiline can start and stop with three single quotes

Type help(str) it will give all function

from def we create functions and then we crea

#!/usr/bin/env python3 in each file like which interpreter to use

In a dynamic type system object types are only resolved at runtime.

Comprehensions in Python : List,Set, Dictionary Comprehensions , Style (Declarative and Functional ),

Generators in Python

Python Developer ToolKit

pip freeze > requirements.txt (save your project dependencies in requirements.txt

Setup.py for installation script

Nose -test package

PIP Installing Package, PyPI – Python Package Index

PIP Commands e.g. pip list, pip show requests , pip search query

Virtualenv or venv for virtual environment, Virtual EnWrapper – Isolated Python Environments

Pylint for code quality

PDB As Python Debugger e.g. python3 -m pdb program-name.py

Python for web development e.g. django, Flask, Pyramid

Tools of Python for Cloud Configuration e.g. Ansible, Boto3 for AWS

Python for Data Analytics e.g Pandas, Matplotlib, Bokeh
Intellij Ultimate

PyChython arm

Python Packaging Authority (PyPA)

>> import sys
>>> sys.path
[”, ‘/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg’, ‘/Library/Python/2.7/site-packages/virtualenvwrapper-4.8.2-py2.7.egg’, ‘/Library/Python/2.7/site-packages/stevedore-1.28.0-py2.7.egg’, ‘/Library/Python/2.7/site-packages/virtualenv_clone-0.2.6-py2.7.egg’, ‘/Library/Python/2.7/site-packages/six-1.11.0-py2.7.egg’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload’, ‘/Library/Python/2.7/site-packages’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python’, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC’]
>>>

Where Python used ?

  • Linux Scripting and Administration
  • Web Development
  • Application Scripting
  • Data Science

Python 2 (pip2,python2,ipython2 – official legacy code)

vs

Python 3

Reference :

https://www.python.org/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s