SlideShare une entreprise Scribd logo
1  sur  56
Télécharger pour lire hors ligne
Avanzado
Parte I

Wednesday, January 30, 13
El Charlista

Wednesday, January 30, 13
@coto
Wednesday, January 30, 13
@coto
Wednesday, January 30, 13
Mobile Framework
JavaScript (2010)
Wednesday, January 30, 13
Mobile Framework
JavaScript (2010)
Wednesday, January 30, 13
Wednesday, January 30, 13
Wednesday, January 30, 13
Wednesday, January 30, 13
Wednesday, January 30, 13
coto@cotos-pro ~
02:15 > python
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Wednesday, January 30, 13
Iniciar Python
coto@cotos-pro ~
02:15 > python
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Wednesday, January 30, 13
• Los programas se ejecutan hasta que se
alcanza EOF

• Con Control-D o Control-Z en el
símbolo de sistema

• o escribe:
raise SystemExit

Wednesday, January 30, 13
Terminar Python
• Los programas se ejecutan hasta que se
alcanza EOF

• Con Control-D o Control-Z en el
símbolo de sistema

• o escribe:
raise SystemExit

Wednesday, January 30, 13
#!/usr/bin/env python
print "Hello World"

Wednesday, January 30, 13
El truco del #!
#!/usr/bin/env python
print "Hello World"

Wednesday, January 30, 13
El truco del #!
#!/usr/bin/env python
print "Hello World"

> python archivo.py

Wednesday, January 30, 13
El truco del #!
#!/usr/bin/env python
print "Hello World"

Wednesday, January 30, 13
El truco del #!
#!/usr/bin/env python
print "Hello World"

> chmod +x archivo.py
> ./archivo.py

Wednesday, January 30, 13
>>> # suma
... 3+5
8
>>> # resta
... 3-4
-1
>>> # multiplicacion
... 2.0*3
6.0

Wednesday, January 30, 13
Operadores
>>> # suma
... 3+5
8
>>> # resta
... 3-4
-1
>>> # multiplicacion
... 2.0*3
6.0

Wednesday, January 30, 13
>>> # division
... 3/2
1.5
>>> # cociente
... 3//2
1
>>> # resto
... 3%2
1

Wednesday, January 30, 13
Operadores
>>> # division
... 3/2
1.5
>>> # cociente
... 3//2
1
>>> # resto
... 3%2
1

Wednesday, January 30, 13
>>> # potencia
... 3**2
9
>>> # left shift
... 5<<2
20
>>> # right shift
... 5>>2
1

Wednesday, January 30, 13
Operadores
>>> # potencia
... 3**2
9
>>> # left shift
... 5<<2
20
>>> # right shift
... 5>>2
1

Wednesday, January 30, 13
>>> # el operador ternario ?:
... ( 5 > 2 ) and “a” or “b”

Wednesday, January 30, 13
Operadores
>>> # el operador ternario ?:
... ( 5 > 2 ) and “a” or “b”

Wednesday, January 30, 13
Operadores
>>> # el operador ternario ?:
... ( 5 > 2 ) and “a” or “b”
“a”

Wednesday, January 30, 13
Operadores
>>> # el operador ternario ?:
... ( 5 > 2 ) and “a” or “b”
“a”

>>> "a" if ( 5 > 2 ) else "b"
“a”

Wednesday, January 30, 13
a
b
c
d
e

=
=
=
=
=

[2,
[2,
[]
[2,
a +

3, 4]
7, 3.5, "Hello"]
[a,b]]
b

#
#
#
#
#

list de enteros
lista mixta
lista vacia
Lista con otra lista
Unir dos listas

#
#
#
#

Obtén el 2º elemento
Obtén una sublista
Listas anidadas
Cambiar un elemento

Manipulando Listas
x = a[1]
y = b[1:3]
z = d[1][0][2]
b[0] = 42

Wednesday, January 30, 13
Listas
a
b
c
d
e

=
=
=
=
=

[2,
[2,
[]
[2,
a +

3, 4]
7, 3.5, "Hello"]
[a,b]]
b

#
#
#
#
#

list de enteros
lista mixta
lista vacia
Lista con otra lista
Unir dos listas

#
#
#
#

Obtén el 2º elemento
Obtén una sublista
Listas anidadas
Cambiar un elemento

Manipulando Listas
x = a[1]
y = b[1:3]
z = d[1][0][2]
b[0] = 42

Wednesday, January 30, 13
f = (2,3,4,5)
g = (,)
h = (2, [3,4], (10,11,12))

# tupla de enteros
# tupla vacia
# tupla mixta

Manipulando Tuplas
x = f[1]
y = f[1:3]
z = h[1][1]

Wednesday, January 30, 13

# Obtén el 2º elemento
# Obtén una porción
# Agrupamiento
Tuplas
f = (2,3,4,5)
g = (,)
h = (2, [3,4], (10,11,12))

# tupla de enteros
# tupla vacia
# tupla mixta

Manipulando Tuplas
x = f[1]
y = f[1:3]
z = h[1][1]

Wednesday, January 30, 13

# Obtén el 2º elemento
# Obtén una porción
# Agrupamiento
Tuplas
f = (2,3,4,5)
g = (,)
h = (2, [3,4], (10,11,12))

# tupla de enteros
# tupla vacia
# tupla mixta

Manipulando Tuplas
x = f[1]
y = f[1:3]
z = h[1][1]

# Obtén el 2º elemento
# Obtén una porción
# Agrupamiento

• Las tuplas son como las listas, pero con tamaño
definido.
• No se pueden reemplazar miembros.
Wednesday, January 30, 13
a = { }
b = { ’x’: 3, ’y’: 4 }
c = { ’uid’: 105,
’login’: ’beazley’,
’name’ : ’David Beazley’
}

Acceso a diccionarios
u = c[’uid’]
c[’shell’] = "/bin/sh"
“name” in c
c.get(“name”, “no value”)

Wednesday, January 30, 13

#
#
#
#

Acceso a un elemento
Crear elemento
Chequear elemento
Chequear elemento
Diccionarios
a = { }
b = { ’x’: 3, ’y’: 4 }
c = { ’uid’: 105,
’login’: ’beazley’,
’name’ : ’David Beazley’
}

Acceso a diccionarios
u = c[’uid’]
c[’shell’] = "/bin/sh"
“name” in c
c.get(“name”, “no value”)

Wednesday, January 30, 13

#
#
#
#

Acceso a un elemento
Crear elemento
Chequear elemento
Chequear elemento
lambda arguments: expression

def name(arguments):
return expression

> f = lambda x, y : x + y
> f(1,1)
2

Wednesday, January 30, 13
Lambdas y Func. Prog.
lambda arguments: expression

def name(arguments):
return expression

> f = lambda x, y : x + y
> f(1,1)
2

Wednesday, January 30, 13
> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
> print map(lambda x: x * 2 + 10, foo)
...[14, 46, 28, 54, 44, 58, 26, 34, 64]
> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
>>> print filter(lambda x: x % 3 == 0, foo)
...[18, 9, 24, 12, 27]
> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
>>> print reduce(lambda x, y: x + y, foo)
...139

Wednesday, January 30, 13
Lambdas y Func. Prog.
> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
> print map(lambda x: x * 2 + 10, foo)
...[14, 46, 28, 54, 44, 58, 26, 34, 64]
> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
>>> print filter(lambda x: x % 3 == 0, foo)
...[18, 9, 24, 12, 27]
> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
>>> print reduce(lambda x, y: x + y, foo)
...139

Wednesday, January 30, 13
#!/usr/bin/env python
def makebold(fn):
def wrapped():
return "<b>" + fn() + "</b>"
return wrapped
def makeitalic(fn):
def wrapped():
return "<i>" + fn() + "</i>"
return wrapped
@makebold
@makeitalic
def hello():
return "hello world"
print hello() ## returns <b><i>hello world</i></b>
Wednesday, January 30, 13
Decorators
#!/usr/bin/env python
def makebold(fn):
def wrapped():
return "<b>" + fn() + "</b>"
return wrapped
def makeitalic(fn):
def wrapped():
return "<i>" + fn() + "</i>"
return wrapped
@makebold
@makeitalic
def hello():
return "hello world"
print hello() ## returns <b><i>hello world</i></b>
Wednesday, January 30, 13
class Account:
def __init__(self, initial):
self.balance = initial
def deposit(self, amt):
self.balance = self.balance + amt
def withdraw(self,amt):
self.balance = self.balance - amt
def getbalance(self):
return self.balance

Wednesday, January 30, 13
Classes
class Account:
def __init__(self, initial):
self.balance = initial
def deposit(self, amt):
self.balance = self.balance + amt
def withdraw(self,amt):
self.balance = self.balance - amt
def getbalance(self):
return self.balance

Wednesday, January 30, 13
a = Account(1000.00)
a.deposit(550.23)
a.deposit(100)
a.withdraw(50)
print a.getbalance()

Wednesday, January 30, 13
Classes
a = Account(1000.00)
a.deposit(550.23)
a.deposit(100)
a.withdraw(50)
print a.getbalance()

Wednesday, January 30, 13
Classes
a = Account(1000.00)
a.deposit(550.23)
a.deposit(100)
a.withdraw(50)
print a.getbalance()

Wednesday, January 30, 13
class Electricity(object):
!
"""Describe the electricity"""
def __init__(self):
# the self variable represents the instance of the object itself.
# Constructor for instances, it will overwrite Class attributes
# when it is called
self._private = 'inside'
self._voltage = 220
 
@property
def voltage(self):
return self._voltage
 
@voltage.setter
def voltage(self, value):
self._voltage = value/2
 
_private = 'outside'
_another_private = 'boo'
@voltage.deleter
def voltage(self):
del self._voltage
 
@staticmethod
def metodo_estatico(val1, val2):
return "Hello %s and %s" % (val1, val2)
 
@classmethod
def metodo_class(cls, val2):
return "Hello %s and %s" % (cls, val2)

Wednesday, January 30, 13
Classes
class Electricity(object):
!
"""Describe the electricity"""
def __init__(self):
# the self variable represents the instance of the object itself.
# Constructor for instances, it will overwrite Class attributes
# when it is called
self._private = 'inside'
self._voltage = 220
 
@property
def voltage(self):
return self._voltage
 
@voltage.setter
def voltage(self, value):
self._voltage = value/2
 
_private = 'outside'
_another_private = 'boo'
@voltage.deleter
def voltage(self):
del self._voltage
 
@staticmethod
def metodo_estatico(val1, val2):
return "Hello %s and %s" % (val1, val2)
 
@classmethod
def metodo_class(cls, val2):
return "Hello %s and %s" % (cls, val2)

Wednesday, January 30, 13
try:
f = open("foo")
except IOError, e:
print "Couldn’t open ’foo’. Error: {}".format(e)

try:
f = open("foo")
except Exception:
print "Couldn’t open ’foo’. Sorry."

Wednesday, January 30, 13
Exceptions
try:
f = open("foo")
except IOError, e:
print "Couldn’t open ’foo’. Error: {}".format(e)

try:
f = open("foo")
except Exception:
print "Couldn’t open ’foo’. Sorry."

Wednesday, January 30, 13
import re
r = re.compile(r’(d+).(d*)’)
m = r.match("42.37")
a = m.group(0)
# Returns ’42.37’
b = m.group(1)
# Returns ’42’
c = m.group(2)
# Returns ’37’
print m.start(2)
# Prints 3

Wednesday, January 30, 13
Expresiones Regulares
import re
r = re.compile(r’(d+).(d*)’)
m = r.match("42.37")
a = m.group(0)
# Returns ’42.37’
b = m.group(1)
# Returns ’42’
c = m.group(2)
# Returns ’37’
print m.start(2)
# Prints 3

Wednesday, January 30, 13
•
•
•
•
•
•
•

Seguridad en Python
Interfaces de Sistema Operativo
Trabajando con Threads
Programando en Red
Interfaces de Base de Datos
Ejecución restringida
Extensiones en C

Wednesday, January 30, 13
Próximamente...
•
•
•
•
•
•
•

Seguridad en Python
Interfaces de Sistema Operativo
Trabajando con Threads
Programando en Red
Interfaces de Base de Datos
Ejecución restringida
Extensiones en C

Wednesday, January 30, 13
Gracias!!
@coto
Wednesday, January 30, 13

Contenu connexe

Tendances

Test du futur avec Spock
Test du futur avec SpockTest du futur avec Spock
Test du futur avec SpockCARA_Lyon
 
밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AINAVER Engineering
 
WordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPWordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPandrewnacin
 
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...tdc-globalcode
 
Beautiful python - PyLadies
Beautiful python - PyLadiesBeautiful python - PyLadies
Beautiful python - PyLadiesAlicia Pérez
 
How fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practiceHow fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practiceTobias Pfeiffer
 
jQuery for Beginners
jQuery for Beginners jQuery for Beginners
jQuery for Beginners NAILBITER
 
Intro to programming games with clojure
Intro to programming games with clojureIntro to programming games with clojure
Intro to programming games with clojureJuio Barros
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版Yutaka Kato
 
Exhibition of Atrocity
Exhibition of AtrocityExhibition of Atrocity
Exhibition of AtrocityMichael Pirnat
 
Test driven game development silly, stupid or inspired?
Test driven game development   silly, stupid or inspired?Test driven game development   silly, stupid or inspired?
Test driven game development silly, stupid or inspired?Eric Smith
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitTobias Pfeiffer
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitTobias Pfeiffer
 
Test Driven Cocos2d
Test Driven Cocos2dTest Driven Cocos2d
Test Driven Cocos2dEric Smith
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2Raghu nath
 

Tendances (20)

Test du futur avec Spock
Test du futur avec SpockTest du futur avec Spock
Test du futur avec Spock
 
밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI
 
WordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPWordPress 3.1 at DC PHP
WordPress 3.1 at DC PHP
 
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
 
Beautiful python - PyLadies
Beautiful python - PyLadiesBeautiful python - PyLadies
Beautiful python - PyLadies
 
Slides
SlidesSlides
Slides
 
Intoduction to php arrays
Intoduction to php arraysIntoduction to php arrays
Intoduction to php arrays
 
How fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practiceHow fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practice
 
Underscore
UnderscoreUnderscore
Underscore
 
jQuery for Beginners
jQuery for Beginners jQuery for Beginners
jQuery for Beginners
 
Intro to programming games with clojure
Intro to programming games with clojureIntro to programming games with clojure
Intro to programming games with clojure
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版
 
Exhibition of Atrocity
Exhibition of AtrocityExhibition of Atrocity
Exhibition of Atrocity
 
Test driven game development silly, stupid or inspired?
Test driven game development   silly, stupid or inspired?Test driven game development   silly, stupid or inspired?
Test driven game development silly, stupid or inspired?
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
Ken20150417
Ken20150417Ken20150417
Ken20150417
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
Test Driven Cocos2d
Test Driven Cocos2dTest Driven Cocos2d
Test Driven Cocos2d
 
Arrays in php
Arrays in phpArrays in php
Arrays in php
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 

En vedette

HE-Isabel ii
HE-Isabel iiHE-Isabel ii
HE-Isabel iiaialo1
 
Tema 9 hidrologia sessió 2
Tema 9 hidrologia sessió 2Tema 9 hidrologia sessió 2
Tema 9 hidrologia sessió 2Sergio Sanchez
 
Hallgrimur Petursson
Hallgrimur Petursson Hallgrimur Petursson
Hallgrimur Petursson elvasg2050
 
Extrait du carnet de voyage new york
Extrait du carnet de voyage  new yorkExtrait du carnet de voyage  new york
Extrait du carnet de voyage new yorkPESLHERBE
 
Transcripcion de Carta a Belice enviada por Eduardo Stein en 1,999 en donde a...
Transcripcion de Carta a Belice enviada por Eduardo Stein en 1,999 en donde a...Transcripcion de Carta a Belice enviada por Eduardo Stein en 1,999 en donde a...
Transcripcion de Carta a Belice enviada por Eduardo Stein en 1,999 en donde a...Belice Esnuestro
 
Presentació Formació Intensiva de Curta Durada
Presentació Formació Intensiva de Curta DuradaPresentació Formació Intensiva de Curta Durada
Presentació Formació Intensiva de Curta DuradaFICD
 
Marco normativo gestion educaiva
Marco normativo gestion educaivaMarco normativo gestion educaiva
Marco normativo gestion educaivaCarmen Guillen Rios
 
Expressionisme alemany
Expressionisme alemanyExpressionisme alemany
Expressionisme alemanyAnna Gelabert
 
Camila bernero valeria iguaran
Camila bernero valeria iguaranCamila bernero valeria iguaran
Camila bernero valeria iguaranMayuli Contreras
 

En vedette (20)

Sanjaya liyanage
Sanjaya liyanageSanjaya liyanage
Sanjaya liyanage
 
HE-Isabel ii
HE-Isabel iiHE-Isabel ii
HE-Isabel ii
 
Tema 9 hidrologia sessió 2
Tema 9 hidrologia sessió 2Tema 9 hidrologia sessió 2
Tema 9 hidrologia sessió 2
 
Hallgrimur Petursson
Hallgrimur Petursson Hallgrimur Petursson
Hallgrimur Petursson
 
TPS 15 Bonggoeya
TPS 15 BonggoeyaTPS 15 Bonggoeya
TPS 15 Bonggoeya
 
the yummy final
the yummy finalthe yummy final
the yummy final
 
Extrait du carnet de voyage new york
Extrait du carnet de voyage  new yorkExtrait du carnet de voyage  new york
Extrait du carnet de voyage new york
 
TPS 18 Bende
TPS 18 BendeTPS 18 Bende
TPS 18 Bende
 
TPS 2 Mataiwoi
TPS 2 MataiwoiTPS 2 Mataiwoi
TPS 2 Mataiwoi
 
Vestido de noiva
Vestido de noiva Vestido de noiva
Vestido de noiva
 
Book.alvaro
Book.alvaroBook.alvaro
Book.alvaro
 
Transcripcion de Carta a Belice enviada por Eduardo Stein en 1,999 en donde a...
Transcripcion de Carta a Belice enviada por Eduardo Stein en 1,999 en donde a...Transcripcion de Carta a Belice enviada por Eduardo Stein en 1,999 en donde a...
Transcripcion de Carta a Belice enviada por Eduardo Stein en 1,999 en donde a...
 
Presentació Formació Intensiva de Curta Durada
Presentació Formació Intensiva de Curta DuradaPresentació Formació Intensiva de Curta Durada
Presentació Formació Intensiva de Curta Durada
 
Escaneado arboles y vegetales
Escaneado arboles y vegetalesEscaneado arboles y vegetales
Escaneado arboles y vegetales
 
սիլվի
սիլվիսիլվի
սիլվի
 
TPS 1 Anggalomelai
TPS 1 AnggalomelaiTPS 1 Anggalomelai
TPS 1 Anggalomelai
 
Marco normativo gestion educaiva
Marco normativo gestion educaivaMarco normativo gestion educaiva
Marco normativo gestion educaiva
 
Expressionisme alemany
Expressionisme alemanyExpressionisme alemany
Expressionisme alemany
 
Camila bernero valeria iguaran
Camila bernero valeria iguaranCamila bernero valeria iguaran
Camila bernero valeria iguaran
 
Artem Tsepelev
Artem TsepelevArtem Tsepelev
Artem Tsepelev
 

Similaire à Python avanzado - parte 1

GoLightly - a customisable virtual machine written in Go
GoLightly - a customisable virtual machine written in GoGoLightly - a customisable virtual machine written in Go
GoLightly - a customisable virtual machine written in GoEleanor McHugh
 
RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”apostlion
 
RではじめるTwitter解析
RではじめるTwitter解析RではじめるTwitter解析
RではじめるTwitter解析Takeshi Arabiki
 
Τα Πολύ Βασικά για την Python
Τα Πολύ Βασικά για την PythonΤα Πολύ Βασικά για την Python
Τα Πολύ Βασικά για την PythonMoses Boudourides
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfsagar414433
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfsagar414433
 
Array matrix example programs - C language
Array matrix example programs - C languageArray matrix example programs - C language
Array matrix example programs - C languageSk_Group
 
Intro to Clojure's core.async
Intro to Clojure's core.asyncIntro to Clojure's core.async
Intro to Clojure's core.asyncLeonardo Borges
 
Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3Eric Evans
 
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲Mohammad Reza Kamalifard
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3Abdul Haseeb
 
Python cheatsheat.pdf
Python cheatsheat.pdfPython cheatsheat.pdf
Python cheatsheat.pdfHimoZZZ
 
第6回 関数とフロー制御
第6回 関数とフロー制御第6回 関数とフロー制御
第6回 関数とフロー制御Wataru Shito
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Paige Bailey
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsBaruch Sadogursky
 

Similaire à Python avanzado - parte 1 (20)

GoLightly - a customisable virtual machine written in Go
GoLightly - a customisable virtual machine written in GoGoLightly - a customisable virtual machine written in Go
GoLightly - a customisable virtual machine written in Go
 
Virtual Machine Constructions for Dummies
Virtual Machine Constructions for DummiesVirtual Machine Constructions for Dummies
Virtual Machine Constructions for Dummies
 
Don't do this
Don't do thisDon't do this
Don't do this
 
RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”
 
Python Day1
Python Day1Python Day1
Python Day1
 
RではじめるTwitter解析
RではじめるTwitter解析RではじめるTwitter解析
RではじめるTwitter解析
 
Τα Πολύ Βασικά για την Python
Τα Πολύ Βασικά για την PythonΤα Πολύ Βασικά για την Python
Τα Πολύ Βασικά για την Python
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
 
Array matrix example programs - C language
Array matrix example programs - C languageArray matrix example programs - C language
Array matrix example programs - C language
 
Intro to Clojure's core.async
Intro to Clojure's core.asyncIntro to Clojure's core.async
Intro to Clojure's core.async
 
Clojure night
Clojure nightClojure night
Clojure night
 
Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3
 
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
 
Web futures
Web futuresWeb futures
Web futures
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
Python cheatsheat.pdf
Python cheatsheat.pdfPython cheatsheat.pdf
Python cheatsheat.pdf
 
第6回 関数とフロー制御
第6回 関数とフロー制御第6回 関数とフロー制御
第6回 関数とフロー制御
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
 

Dernier

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 

Dernier (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Python avanzado - parte 1

  • 11. coto@cotos-pro ~ 02:15 > python Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> Wednesday, January 30, 13
  • 12. Iniciar Python coto@cotos-pro ~ 02:15 > python Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> Wednesday, January 30, 13
  • 13. • Los programas se ejecutan hasta que se alcanza EOF • Con Control-D o Control-Z en el símbolo de sistema • o escribe: raise SystemExit Wednesday, January 30, 13
  • 14. Terminar Python • Los programas se ejecutan hasta que se alcanza EOF • Con Control-D o Control-Z en el símbolo de sistema • o escribe: raise SystemExit Wednesday, January 30, 13
  • 15. #!/usr/bin/env python print "Hello World" Wednesday, January 30, 13
  • 16. El truco del #! #!/usr/bin/env python print "Hello World" Wednesday, January 30, 13
  • 17. El truco del #! #!/usr/bin/env python print "Hello World" > python archivo.py Wednesday, January 30, 13
  • 18. El truco del #! #!/usr/bin/env python print "Hello World" Wednesday, January 30, 13
  • 19. El truco del #! #!/usr/bin/env python print "Hello World" > chmod +x archivo.py > ./archivo.py Wednesday, January 30, 13
  • 20. >>> # suma ... 3+5 8 >>> # resta ... 3-4 -1 >>> # multiplicacion ... 2.0*3 6.0 Wednesday, January 30, 13
  • 21. Operadores >>> # suma ... 3+5 8 >>> # resta ... 3-4 -1 >>> # multiplicacion ... 2.0*3 6.0 Wednesday, January 30, 13
  • 22. >>> # division ... 3/2 1.5 >>> # cociente ... 3//2 1 >>> # resto ... 3%2 1 Wednesday, January 30, 13
  • 23. Operadores >>> # division ... 3/2 1.5 >>> # cociente ... 3//2 1 >>> # resto ... 3%2 1 Wednesday, January 30, 13
  • 24. >>> # potencia ... 3**2 9 >>> # left shift ... 5<<2 20 >>> # right shift ... 5>>2 1 Wednesday, January 30, 13
  • 25. Operadores >>> # potencia ... 3**2 9 >>> # left shift ... 5<<2 20 >>> # right shift ... 5>>2 1 Wednesday, January 30, 13
  • 26. >>> # el operador ternario ?: ... ( 5 > 2 ) and “a” or “b” Wednesday, January 30, 13
  • 27. Operadores >>> # el operador ternario ?: ... ( 5 > 2 ) and “a” or “b” Wednesday, January 30, 13
  • 28. Operadores >>> # el operador ternario ?: ... ( 5 > 2 ) and “a” or “b” “a” Wednesday, January 30, 13
  • 29. Operadores >>> # el operador ternario ?: ... ( 5 > 2 ) and “a” or “b” “a” >>> "a" if ( 5 > 2 ) else "b" “a” Wednesday, January 30, 13
  • 30. a b c d e = = = = = [2, [2, [] [2, a + 3, 4] 7, 3.5, "Hello"] [a,b]] b # # # # # list de enteros lista mixta lista vacia Lista con otra lista Unir dos listas # # # # Obtén el 2º elemento Obtén una sublista Listas anidadas Cambiar un elemento Manipulando Listas x = a[1] y = b[1:3] z = d[1][0][2] b[0] = 42 Wednesday, January 30, 13
  • 31. Listas a b c d e = = = = = [2, [2, [] [2, a + 3, 4] 7, 3.5, "Hello"] [a,b]] b # # # # # list de enteros lista mixta lista vacia Lista con otra lista Unir dos listas # # # # Obtén el 2º elemento Obtén una sublista Listas anidadas Cambiar un elemento Manipulando Listas x = a[1] y = b[1:3] z = d[1][0][2] b[0] = 42 Wednesday, January 30, 13
  • 32. f = (2,3,4,5) g = (,) h = (2, [3,4], (10,11,12)) # tupla de enteros # tupla vacia # tupla mixta Manipulando Tuplas x = f[1] y = f[1:3] z = h[1][1] Wednesday, January 30, 13 # Obtén el 2º elemento # Obtén una porción # Agrupamiento
  • 33. Tuplas f = (2,3,4,5) g = (,) h = (2, [3,4], (10,11,12)) # tupla de enteros # tupla vacia # tupla mixta Manipulando Tuplas x = f[1] y = f[1:3] z = h[1][1] Wednesday, January 30, 13 # Obtén el 2º elemento # Obtén una porción # Agrupamiento
  • 34. Tuplas f = (2,3,4,5) g = (,) h = (2, [3,4], (10,11,12)) # tupla de enteros # tupla vacia # tupla mixta Manipulando Tuplas x = f[1] y = f[1:3] z = h[1][1] # Obtén el 2º elemento # Obtén una porción # Agrupamiento • Las tuplas son como las listas, pero con tamaño definido. • No se pueden reemplazar miembros. Wednesday, January 30, 13
  • 35. a = { } b = { ’x’: 3, ’y’: 4 } c = { ’uid’: 105, ’login’: ’beazley’, ’name’ : ’David Beazley’ } Acceso a diccionarios u = c[’uid’] c[’shell’] = "/bin/sh" “name” in c c.get(“name”, “no value”) Wednesday, January 30, 13 # # # # Acceso a un elemento Crear elemento Chequear elemento Chequear elemento
  • 36. Diccionarios a = { } b = { ’x’: 3, ’y’: 4 } c = { ’uid’: 105, ’login’: ’beazley’, ’name’ : ’David Beazley’ } Acceso a diccionarios u = c[’uid’] c[’shell’] = "/bin/sh" “name” in c c.get(“name”, “no value”) Wednesday, January 30, 13 # # # # Acceso a un elemento Crear elemento Chequear elemento Chequear elemento
  • 37. lambda arguments: expression def name(arguments): return expression > f = lambda x, y : x + y > f(1,1) 2 Wednesday, January 30, 13
  • 38. Lambdas y Func. Prog. lambda arguments: expression def name(arguments): return expression > f = lambda x, y : x + y > f(1,1) 2 Wednesday, January 30, 13
  • 39. > foo = [2, 18, 9, 22, 17, 24, 8, 12, 27] > print map(lambda x: x * 2 + 10, foo) ...[14, 46, 28, 54, 44, 58, 26, 34, 64] > foo = [2, 18, 9, 22, 17, 24, 8, 12, 27] >>> print filter(lambda x: x % 3 == 0, foo) ...[18, 9, 24, 12, 27] > foo = [2, 18, 9, 22, 17, 24, 8, 12, 27] >>> print reduce(lambda x, y: x + y, foo) ...139 Wednesday, January 30, 13
  • 40. Lambdas y Func. Prog. > foo = [2, 18, 9, 22, 17, 24, 8, 12, 27] > print map(lambda x: x * 2 + 10, foo) ...[14, 46, 28, 54, 44, 58, 26, 34, 64] > foo = [2, 18, 9, 22, 17, 24, 8, 12, 27] >>> print filter(lambda x: x % 3 == 0, foo) ...[18, 9, 24, 12, 27] > foo = [2, 18, 9, 22, 17, 24, 8, 12, 27] >>> print reduce(lambda x, y: x + y, foo) ...139 Wednesday, January 30, 13
  • 41. #!/usr/bin/env python def makebold(fn): def wrapped(): return "<b>" + fn() + "</b>" return wrapped def makeitalic(fn): def wrapped(): return "<i>" + fn() + "</i>" return wrapped @makebold @makeitalic def hello(): return "hello world" print hello() ## returns <b><i>hello world</i></b> Wednesday, January 30, 13
  • 42. Decorators #!/usr/bin/env python def makebold(fn): def wrapped(): return "<b>" + fn() + "</b>" return wrapped def makeitalic(fn): def wrapped(): return "<i>" + fn() + "</i>" return wrapped @makebold @makeitalic def hello(): return "hello world" print hello() ## returns <b><i>hello world</i></b> Wednesday, January 30, 13
  • 43. class Account: def __init__(self, initial): self.balance = initial def deposit(self, amt): self.balance = self.balance + amt def withdraw(self,amt): self.balance = self.balance - amt def getbalance(self): return self.balance Wednesday, January 30, 13
  • 44. Classes class Account: def __init__(self, initial): self.balance = initial def deposit(self, amt): self.balance = self.balance + amt def withdraw(self,amt): self.balance = self.balance - amt def getbalance(self): return self.balance Wednesday, January 30, 13
  • 48. class Electricity(object): ! """Describe the electricity""" def __init__(self): # the self variable represents the instance of the object itself. # Constructor for instances, it will overwrite Class attributes # when it is called self._private = 'inside' self._voltage = 220   @property def voltage(self): return self._voltage   @voltage.setter def voltage(self, value): self._voltage = value/2   _private = 'outside' _another_private = 'boo' @voltage.deleter def voltage(self): del self._voltage   @staticmethod def metodo_estatico(val1, val2): return "Hello %s and %s" % (val1, val2)   @classmethod def metodo_class(cls, val2): return "Hello %s and %s" % (cls, val2) Wednesday, January 30, 13
  • 49. Classes class Electricity(object): ! """Describe the electricity""" def __init__(self): # the self variable represents the instance of the object itself. # Constructor for instances, it will overwrite Class attributes # when it is called self._private = 'inside' self._voltage = 220   @property def voltage(self): return self._voltage   @voltage.setter def voltage(self, value): self._voltage = value/2   _private = 'outside' _another_private = 'boo' @voltage.deleter def voltage(self): del self._voltage   @staticmethod def metodo_estatico(val1, val2): return "Hello %s and %s" % (val1, val2)   @classmethod def metodo_class(cls, val2): return "Hello %s and %s" % (cls, val2) Wednesday, January 30, 13
  • 50. try: f = open("foo") except IOError, e: print "Couldn’t open ’foo’. Error: {}".format(e) try: f = open("foo") except Exception: print "Couldn’t open ’foo’. Sorry." Wednesday, January 30, 13
  • 51. Exceptions try: f = open("foo") except IOError, e: print "Couldn’t open ’foo’. Error: {}".format(e) try: f = open("foo") except Exception: print "Couldn’t open ’foo’. Sorry." Wednesday, January 30, 13
  • 52. import re r = re.compile(r’(d+).(d*)’) m = r.match("42.37") a = m.group(0) # Returns ’42.37’ b = m.group(1) # Returns ’42’ c = m.group(2) # Returns ’37’ print m.start(2) # Prints 3 Wednesday, January 30, 13
  • 53. Expresiones Regulares import re r = re.compile(r’(d+).(d*)’) m = r.match("42.37") a = m.group(0) # Returns ’42.37’ b = m.group(1) # Returns ’42’ c = m.group(2) # Returns ’37’ print m.start(2) # Prints 3 Wednesday, January 30, 13
  • 54. • • • • • • • Seguridad en Python Interfaces de Sistema Operativo Trabajando con Threads Programando en Red Interfaces de Base de Datos Ejecución restringida Extensiones en C Wednesday, January 30, 13
  • 55. Próximamente... • • • • • • • Seguridad en Python Interfaces de Sistema Operativo Trabajando con Threads Programando en Red Interfaces de Base de Datos Ejecución restringida Extensiones en C Wednesday, January 30, 13