De 0 A Python En 40 Minutos

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    De 0 A Python En 40 Minutos - Presentation Transcript

    1. De 0 a Python en 40 minutos (tranquilos que no pica)
    2. Python es: • Un lenguaje de programacion de alto nivel • Dinamico • Multiparadigma (funcional y OO) • Multiplataforma • Un tipo de serpiente
    3. Sirve para: • Aplicaciones de escritorio y consola (QT, GTK+,wxWidgets, etc) • Scripting de aplicaciones en otros lenguajes (Jython, IronPython, etc) • System scripting • Aplicaciones y sistemas web • Recuperar el placer de programar
    4. Algunas caracteristicas: • Gratis y Libre ( y Open Source, todo por el mismo precio) • Maduro (casi 20 años) • Diseño minimalista, elegante y robusto • Facil de aprender (se lee como pseudocodigo) • Expremadamente portable (Unix, Windows, Mac, Amiga, BeOS, Win/CE, DOS, OS/2, VMS, Cray, y muchas otras)
    5. Que tiene de interesante? • Alto poder expresivo • Potente soporte de listas y diccionarios • Modo interactivo
    6. Listas y diccionarios lista=*1,2,3,’cuatro’,objeto.metodo,*‘una’,’lista’,’anidada’++ Diccionario=,‘clave’:’valor’,1:*‘a’,’b’,’c’+,’lista’:lista} eventos=,‘onClick’: window.show, ’onESC’:window.close} >>>evento=‘Click’ >>>eventos.get(‘on’+evento)()
    7. List Comprehension (Listas por comprencion) • Permite definir listas sin declarar explicitamente su contenido [<expresion> for <valor> in <coleccion> if <condicion>] Por ej: >>> [n for n in range(10) if n % 2 == 0 ] [0, 2, 4, 6, 8] >>> [n*n for n in range(5)] [0, 1, 4, 9, 16] >>>def esPar(n): return ((n%2) == 0) >>> [ n for n in range(10) if isPar(n) ] [0, 2, 4, 6, 8]
    8. Generadores def primos(): n = 2 listaPrimos = [] while True: if not any(n % f == 0 for f in listaPrimos): yield n listaPrimos.append(n) n += 1
    9. Y para que sirve? • En Python todo es un diccionario • Por ej, los archivos: >>archivo=open(“ texto.txt”) >>for (linea in archivo): print(linea) Los objetos tambien pueden verse asi…
    10. Tirandose de cabeza: listas en accion Objetivo: insertar en una base de datos el contenido de un archivo CSV hubicado en un sitio web import MySQLdb conn = MySQLdb.connect (host = "localhost", user = "testuser", passwd = "testpass", db = "test") ejecutar=conn.cursor().execute def insertar(nombre,apellido,email): ejecutar(“INSERT INTO gente(“+nombre+’,’+apellido+’,’email+’)’) datos= urlopen("http://misitio.com/datos.csv") for (linea in datos): map(insertar,linea.split(“,”)) Epa! cursor.close () conn.close ()
    11. Modo interactivo import mechanize br = mechanize.Browser() br.open("http://www.veraz.com.ar/") # y ahora??? >>>br.select_form(name=“login_form") #recibo un error informando que el formulario no existe >>>br.open("http://www.veraz.com.ar/login") #el form estaba en un frame >>>br.select_form(name=“login_form") #ahora si anda >>>br*“user"+ = “elusuario“ >>>br*“password"+ = “laclave“ Te quiero ver >>>respuesta = br.submit() haciendo esto en >>>print respuesta.geturl() # queria ir aca? C++ o Java…(si >>>respuesta=br.follow_link(“continuar“) podes…) >>>print respuesta .read() #veo el HTML de la pagina a donde me mando >>>archivo = file('test.html', 'w') >>>archivo.write(respuesta.read()) >>>archivo.close()
    12. Duck Typing “Si se ve como un pato, se mueve como un pato y suena como un pato, entonces debe ser un pato.”
    13. Ejemplo class TorresGemelas class EnanoEnfurecido def explotar(): def explotar(): print(“PUM!!”) print(“Callate gil!”) def reventar(cosa): cosa.explotar() >>reventar(TorresGemelas) PUM!! >>reventar(EnanoEnfurecido) Callate Gil!
    14. Ejemplos de uso Proyectos grosos Aplicaciones: Juegos: • Youtube •BitTorrent •Frets on Fire • Gmail •Bazaar •Civilization 4 •Mercurial •Battlefield 2 • GoogleGroups •YUM •Eve Online • GoogleMaps •Portage • Reddit •Trac Como lenguaje de scripting: •Blender •Paint Shop Pro •Maya •Amarok •Poser •Totem •Inkscape •VIM •GIMP
    15. Influencia en otros lenguajes • ECMAScritp incorporo iteradores, generadores, y list comprehensions • Groovy surgio para llevar la filosofia de Python a Java • Ocaml tiene una sintaxis opcional, llamada “twt” (The Whitespace Thing), inspirada por Python y Haskell
    16. Mas informacion • Sitio oficial de Python: www.python.org • Grupo de usuarios PyAr www.python.org.ar • Google
    17. Preguntas
    SlideShare Zeitgeist 2009

    + flekosoflekoso Nominate

    custom

    247 views, 0 favs, 2 embeds more stats

    Charla introductoria al lenguaje Python dictada por more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 247
      • 236 on SlideShare
      • 11 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 8
    Most viewed embeds
    • 10 views on http://blogs.sun.com
    • 1 views on http://planets.sun.com

    more

    All embeds
    • 10 views on http://blogs.sun.com
    • 1 views on http://planets.sun.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories