SlideShare uma empresa Scribd logo
1 de 56
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 

Último (20)

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 

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