Python is a widely used high-level, general-purpose, interpreted programming language. It provides constructs intended to enable clear programs on both small and large scale. Python features a dynamic type system and automatic memory management and supports multiple programming paradigms, including object-oriented, imperative, functional and procedural styles. It has a large and comprehensive standard library.
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Presentation of Python, Django, DockerStack
1.
2. 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
3. Python: advantages
Simple
Easy to study
Free and open source
High-level programming language
Portability
Expansibility
Embedability
Large and comprehensive standard libraries
Canonical code
4. Python: syntax and semantics
Use whitespace indentation to delimit blocks
if, else and elif
for, while
try, except, finally
class
def (function and method)
with
pass
assert
yield (generator)
import
print, print()
self, this
5. Python: typing
str Character string 'Wikipedia'
"Wikipedia"
"""Spanning
multiple
lines"""
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
6. 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
7. 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
"""
8. 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
9. 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
11. 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
15. 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
17. 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
18. 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
19. 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
20. 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;
22. 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
23. 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 !!!)