KEMBAR78
Python 101 | ODP
PYTHON 101
Julián Perelli
@jperelli
Cualbondi
Mainstorconcept
Docente UTN FRLP
Historia
Guido van Rossum
Python's
Benevolent
Dictator for Life
“In December 1989, I was
looking for a "hobby"
programming project that
would keep me occupied
during the week around
Christmas”
Guido van Rossum
“I decided to write an
interpreter for the new
scripting language I had
been thinking about lately:
a descendant of ABC that
would appeal to Unix/C
hackers.”
Guido van Rossum
●
CWI, Centrum
Wiskunde &
Informatica
●
Google
●
Dropbox
Monty python
Filosofía
The zen of python
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
The zen of python
Beautiful is better than ugly.
Simple is better than complex.
Flat is better than nested.
Readability counts.
Fanatismo
Premature optimization vs clarity
Pythonic
Pythonista
Features
Multiparadigma
(Propósito general)
Imperativo + procedural
Orientado a Objetos
Funcional
- map / reduce / filter /comprehensions / generators
Features
Tipado dinámico
- No se declaran variables
- Las variables pueden cambiar de tipo en tiempo
de ejecución
Garbage collector
Full unicode (utf8) support
Sintaxis
Sintaxis: Expresiones
a = 1
b = a + 2
a = “Hola”
b = “ Mundo”
print a + b
Sintaxis: Convenciones
Sintaxis: Convenciones
if (condition) {
/* statements */
}
if (condition)
{
/* statements */
}
if (condition)
{
/* statements */
}
if (condition)
{
if (condition){
/* statements */
}
if (condition) {
/* statements */
}
if (condition)
{
/* statements */
}
if (condition) {/* statements
if (condition){
Sintaxis: Convenciones
Tabs vs Espacios
Sintaxis: Convenciones
Tabs vs Espacios
Sintaxis: Control
if a < b:
print “a es”
print “menor”
else:
print “a es mayor o
igual”
Sintaxis: Loop
for e in [1, 5, “pepe”]:
print e
Sintaxis
void bubble_sort (int *a, int n) {
int i, t, s = 1;
while (s) {
s = 0;
for (i = 1; i < n; i++) {
if (a[i] < a[i - 1]) {
t = a[i];
a[i] = a[i - 1];
a[i - 1] = t;
s = 1;
}
}
}
}
def bubble_sort(a):
s = True
while s:
s = False
for i in xrange(len(a) - 1):
if a[i] > a[i+1]:
a[i], a[i+1] = a[i+1], a[i]
s = True
return None
Sintaxis
void bubble_sort (int *a, int n) {
int i, t, s = 1;
while (s) {
s = 0;
for (i = 1; i < n; i++) {
if (a[i] < a[i - 1]) {
t = a[i];
a[i] = a[i - 1];
a[i - 1] = t;
s = 1;
}
}
}
}
def bubble_sort(a):
s = True
while s:
s = False
for i in xrange(len(a) - 1):
if a[i] > a[i+1]:
a[i], a[i+1] = a[i+1], a[i]
s = True
return None
Sintaxis ofuscada
void bubble_sort (int *a, int n) {int i, t, s = 1;while (s) {s = 0;
for (i = 1; i < n; i++) {if (a[i] < a[i - 1]) {t = a[i];a[i] = a[i - 1];a[i - 1] = t;s =
1;}}}}
def bubble_sort(a):
s = True
while s:
s = False
for i in xrange(len(a) - 1):
if a[i] > a[i+1]:
a[i], a[i+1] = a[i+1], a[i]
s = True
return None
Comunidad
Comunidad: Paquetes
Pypi
pip install paquete
Comunidad: Paquetes
Me voy a node.js?
Me voy a node.js?
NO
Diferentes propósitos
Node's early packaging
Comunidad: Github
Quién lo usa
Infraestructura (scripting linux)
Web sites
Math experts
Standalone PC apps
Quien lo usa
Quien no lo usa?
Quien no lo usa?
¿Qué esperás?
Gracias!

Python 101