Professional Documents
Culture Documents
Primeros Pasos
Juan Jos Iglesias Gonzlez bille@gpul.org Adrin Prez de Castro moebius@gpul.org
Guin
Spam & Eggs Why Python? Lets be friends!
Why Python?
Razones, hechos y ejemplos de por qu puede ser conveniente tener un reptil a mano
bl o q u e
import sys ide ntid ad name = sys.argv do i n dexa if len(name) == 2: ! print Hello + name[1] concat else: print Hello random chorbo
lst = [spam, and] lst.append(3) lst.append(eggs) for item in lst: print item, o
i nt r
l i st a
ado r i te r
# We also have while i = 0 polim . while i < len(lst): . print lst[i], de nt n i i += 1 # But not i++!!
d = { eggs: 3, milk: 1 } d[cornbeef] = some print Supermarket List: for item in d: ! print * 3, d[item], item
c a st
m u lt.
c o mp re s .
Pitonizacin recursiva
AE W
Why Python? OO
Tratando reptiles como objetos
las c e
class Reptile: def __init__(self, name=Pitty, **a): self._name = name h as h t r i b. a self._attr = a to do def y(self, name): m return self._attr.get(name) def x(self): return self._name
bj . o
defe ct
p = Reptile(Python, age=5, eyes=blue) q = Reptile(Boa, age=3, length=2) print p.x(), p.y(age), p.y(eyes) print q.x(), q.y(age), q.y(eyes) p._name = MutantPython o c u lto? print p.x()
No n e
Lets be friends!
Miedo a estar slo? Python tiene todas las respuestas
Interoperabilidad
.NET, Jython (Java), SWIG (C & C++), PyObjC (Cocoa), Corba
Aplicaciones cliente/servidor
BitTorrent, Nicotine, PyMusique
Juegos
PyGame, PyDance
Gracias, Bryan