Python: introduction
First release in 1991
Based on C and Java
Stable releases are: (2.7.x, 3.5.x)
Cross-platform
Object-oriented, imperative, functional programming, and procedural styles
Python: advantages
SimpleEasy to studyFree and open sourceHigh-level programming languagePortabilityExpansibilityEmbedabilityLarge and comprehensive standard librariesCanonical code
Python: syntax and semantics
Use whitespace indentation to delimit blocks
if, else and eliffor, whiletry, except, finallyclassdef (function and method)withpassassertyield (generator)importprint, print()self, this
Python: typing
str Character string 'Wikipedia'"Wikipedia""""Spanningmultiplelines"""
Bytearray, bytes
Sequence of bytes bytearray(b'Some ASCII')bytearray([119, 105, 107, 105])b"Some ASCII"bytes([119, 105, 107, 105])
list List, can contain mixed types [4.0, 'string', True]
tuple Can contain mixed types (4.0, 'string', True)
set Unordered set {4.0, 'string', True}
frozenset Unordered set frozenset([4.0, 'string', True])
dict Associative array {'key1': 1.0, 3: False}
complex Complex number 3+2.7j
Python: code sample
1 # Function definition is here 2 def printme(str): 3 """This prints a passed string into this function""" 4 print str 5 return 6 7 8 # Now you can call printme function 9 printme("I'm first call to user defined function!") 10
Files- .py, .pyc, .pyd, .pyo (prior to
3.5), .pyw, .pyz (since 3.5)
Packages- __init__.py
Python: class sample
1 class Person:2 3 def __init__(self, name): 4 self.name = name 5 6 def say_hello(self): 7 print "Hello, my name is", self.name 8 9 def __del__(self): 10 print '%s says bye' % self.name 11 12 p = Person('David Sanchez') 13 p.say_hello()14
This example includes class definition, constructor function, destructor function, attributes and methods definition and object definition.
""" This code sample will return: Hello, my name is David Sanchez David Sanchez says bye Process finished with exit code 0 """
Python: inheritance sample
1 class Person: 2 def speak(self): 3 print 'I can speak' 4 5 6 class Man(Person): 7 def wear(self): 8 print 'I wear shirt' 9 10 11 class Woman(Person): 12 def wear(self): 13 print 'I wear skirt' 14 15 man = Man() 16 man.wear() 17 man.speak() 18 19 woman = Woman() 20 woman.wear() 21 woman.speak() 22
""" This code sample will return: I wear shirt I can speak I wear skirt I can speak Process finished with exit code 0 """
Just like JAVA, subclass can invoke Attributes and methods in superclass.
Supports multiple inheritance.
1 class Alien(Person, Man, Woman): 2 pass
PyCharm: overview
IDE for Python language by JetBrains
Cross-platform
Web development frameworks (Django, Flask, ...)
Cross-technology development (JavaScript, SQL, HTML, CSS, ...)
Profiler, Code generation, refactoring
Database integration
Django: overview
Initial release: 2005
Free, open-source, ModelTemplateView web framework
Include optional C.R.U.D. interface
Caching and internationalization system
Database (PostgreSQL, MySQL, SQLite) easy integration and migration
Easy forms creation and manipulation
Python Tools: overview
pip:- Package management system (like composer)- Install and manage software packages written in Python
virtualenv:- Isolate pip install in a python project
setuptools:- build and distribute a python app with dependencies on other packages
wheel:- setuptools extension for creating wheel distributions
Manage servers- Add- Edit- Remove
Manage databases- Add- Edit- Remove
Copy link to backup file- Copy last backup SQL file- Copy available backup SQL file
Project key
Project name
Project type- Maintenance- Project
Timesheet activities- Spécifications- Gestion de projet- Administration Système- Formations- Avant-vente- Développement Backend- Développement Frontend- Contrôle qualité- Direction Artistique- Web Design
Project lead- Nicolas Gommenginger- Thaïs Heuzé
nginx: used as a delivery server for static (JS, CSS, images) files.
gunicorn: WSGI HTTP Server
RabbitMQ: open source message broker software
Celery: asynchronous task queue manager
Celery is useful for background task processing and deferred execution in Django. Task queues are used to distribute work across workers.
Celery's components:
- message broker - component for exchange messages and tasks distribution between workers: RabbitMQ;
- worker - calculation unit, which execute task;
Overview
An utility to Dockerize your applications and generate minimal docker requires files:
➔ Dockerfile
➔ docker-compose.yml
➔ php.ini
Projects stored at:
/home/{user}/DockerStackProjects/
https://github.com/emulienfou/dockerstack
Available commands
●start: Build and start a new project
●stop: Stop docker container(s) for the current project
●build: Build a new or existing project
● rm: Remove one or more projects
●ps: List all created projects
●updb: Update database, providing an SQL file (!!! not yet available !!!)