SlideShare ist ein Scribd-Unternehmen logo
1 von 58
Python para la Plataforma Java
               Leo Soto M.



  Jornadas Regionales del Software Libre 2009
Avisos Comerciales...
Python para la plataforma Java
¿Plataforma Java sin Java?
http://www.flickr.com/photos/lab2112/457187539/
Plataforma Java con Java
y Python, Ruby, Scala, Groovy...
¿Por qué Python?
“Python is an experiment in how much freedom
             programmers need...”
“...Too much freedom and nobody can read
another's code; too little and expressiveness is
                 endangered”

                       - Guido van Rossum, 1996
Python
Dinámico, flexible, extremadamente legible
Jython
Dinámico, flexible, extremadamente legible

   En una plataforma ubicua, sólida
http://www.flickr.com/photos/mushon/282287572/
1997
Jython!
Jython, 12 años después




               http://www.flickr.com/photos/digital-noise/3650559857/
2.5.1
Full compatibilidad con CPython
web2py


etree             nose


 setuptools   virtualenv
OK
¿Pero qué puedo hacer con Jython
             hoy?
GUIs
Demo con Swing
De Java a Jython
final JFrame frame = new JFrame("HelloSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);
frame = JFrame("HelloSwing")
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
frame.setSize(300,300)
frame = JFrame("HelloSwing",
               defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
               size=(300, 300))
Container content = frame.getContentPane();
content.setLayout(new FlowLayout());
content = frame.contentPane
content.setLayout(new FlowLayout());
content = frame.contentPane
content.layout = FlowLayout()
JButton botonSaludar = new JButton("Saludar");
JButton botonDespedir = new JButton("Despedirse");
botonSaludar.addActionListener(new ActionListener() {
	 public void actionPerformed(ActionEvent e) {
	 	 JOptionPane.showMessageDialog(frame, "Hola!");
	 }
});
botonDespedir.addActionListener(new ActionListener() {
	 public void actionPerformed(ActionEvent e) {
	 	 JOptionPane.showMessageDialog(frame, "Chao!");
	 	 frame.dispose();
	 }
});
content.add(botonSaludar);
content.add(botonDespedir);
def saludar(event):
    JOptionPane.showMessageDialog(frame, "Hola!")

def despedir(event):
    JOptionPane.showMessageDialog(frame, "Chao!")
    frame.dispose()

content.add(JButton("Saludar", actionPerformed=saludar))
content.add(JButton("Despedirse", actionPerformed=despedir))
Otra demo con Swing
(Si es que tenemos acceso a internet)
Créditos: Frank Wierzbicki
Web
Demo con Django
Y sólo por diversión...
### View
#!/usr/bin/env python
                                                            from django import http
"""
                                                            from django.template import Template, Context
WSW - the World's Shittiest Wiki.
"""
                                                            def wsw(request, title):
import re
                                                                title = urllib.unquote_plus(title) if title else "Home"
import urllib
                                                                p, created = Page.objects.get_or_create(title=title)
from django.conf import settings
                                                                form = PageForm(instance=p)
                                                                if request.method == "POST":
### Config
                                                                     form = PageForm(request.POST, instance=p)
settings.configure(
                                                                     form.save()
    DEBUG = True,
                                                                     return http.HttpResponseRedirect(request.get_full_path())
    DATABASE_ENGINE =   "doj.backends.zxjdbc.postgresql",
                                                                else:
    DATABASE_NAME   =   "wsw",
                                                                     form = PageForm(instance=p)
    DATABASE_USER   =   "wsw",
                                                                     t = Template("""<h1>{{ p.title }}</h1><ul>{% for p in
    DATABASE_PASSWORD   = "wsw",
                                                            allpages %}<li><a href="{{ p }}">{{ p }}</a></li>{% endfor %}
    ROOT_URLCONF    =   __name__)
                                                            </ul><form action="{{ request.get_full_path }}" method="POST">
                                                            <p>{{ form.content }}</p><input type="submit"></form>""")
### Model
                                                                wikiwords = re.findall(
from django.db import models
                                                                         '[A-Z][a-z]+[A-Z][a-z]+(?:[A-Z][a-z]+)*', p.content)
                                                                allpages = [
class Page(models.Model):
                                                                         page.title for page in Page.objects.order_by('title')]
    title = models.CharField(max_length=300,
                                                                allpages.extend(
                             primary_key=True)
                                                                         word for word in wikiwords if word not in allpages)
    content = models.TextField()
                                                                return http.HttpResponse(t.render(Context(locals())))
    class Meta:
                                                            ### Main
        app_label = "wsw"
                                                            if __name__ == '__main__':
                                                                from django.core import management
### URLs
                                                                from django.db import connection
from django.conf.urls.defaults import *
                                                                from django.core.management.color import no_style
                                                                cursor = connection.cursor()
urlpatterns = patterns(__name__, ('(.*)', 'wsw'))
                                                                statements, _ = connection.creation.sql_create_model(
                                                                         Page, no_style())
### Form
                                                                try:
from django.forms import ModelForm
                                                                     for sql in statements:
                                                                         cursor.execute(sql)
class PageForm(ModelForm):
                                                                     connection.connection.commit()
    class Meta:
                                                                except:
        model = Page
                                                                     pass
        fields = ['content']
                                                                management.call_command('runserver')
Créditos: Jacob Kaplan-Moss
Testing




   http://www.flickr.com/photos/emotionaltoothpaste/26034597/
DocTests
def factorial(n):
                                         It must also not be ridiculously large:
    """Return the factorial of n, an
                                         >>> factorial(1e100)
    exact integer >= 0.
                                         Traceback (most recent call last):
                                             ...
   If the result is small enough to
                                         OverflowError: n too large
   fit in an int, return an int.
                                         """
   Else return a long.

                                         import math
   >>> [factorial(n)
                                         if not n >= 0:
   ... for n in range(6)]
                                             raise ValueError("n must be >= 0")
   [1, 1, 2, 6, 24, 120]
                                         if math.floor(n) != n:
   >>> [factorial(long(n))
                                             raise ValueError(
   ... for n in range(6)]
                                                 "n must be exact integer")
   [1, 1, 2, 6, 24, 120]
                                         if n+1 == n: # catch a value like 1e300
   >>> factorial(30)
                                             raise OverflowError("n too large")
   265252859812191058636308480000000L
                                         result = 1
   >>> factorial(30L)
                                         factor = 2
   265252859812191058636308480000000L
                                         while factor <= n:
   >>> factorial(-1)
                                             result *= factor
   Traceback (most recent call last):
                                             factor += 1
       ...
                                         return result
   ValueError: n must be >= 0

   Factorials of floats are OK, but
   the float must be an exact integer:
   >>> factorial(30.1)
   Traceback (most recent call last):
       ...
   ValueError: n must be exact integer
   >>> factorial(30.0)
   265252859812191058636308480000000L
Demo de (ab)uso de DocTest
¿Por cierto, quien más usa Jython?
EADS




http://www.flickr.com/photos/nguyendai/694158734/
Lockheed Martin




http://www.flickr.com/photos/rcsj/2504022678/
¿Y dónde puedo aprender más?
jythonbook.com
¿Preguntas?
      Contacto:

       @leosoto
http://blog.leosoto.com
¡Gracias!
      Contacto:

       @leosoto
http://blog.leosoto.com

Weitere ähnliche Inhalte

Was ist angesagt?

Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 Talk: Unit TestingPython Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 Talk: Unit TestingPython Ireland
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applicationsSkills Matter
 
Topological indices (t is) of the graphs to seek qsar models of proteins com...
Topological indices (t is) of the graphs  to seek qsar models of proteins com...Topological indices (t is) of the graphs  to seek qsar models of proteins com...
Topological indices (t is) of the graphs to seek qsar models of proteins com...Jitendra Kumar Gupta
 
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]MongoDB
 
Object Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHPObject Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHPChad Gray
 
Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design PatternsHugo Hamon
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistenceHugo Hamon
 
The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212Mahmoud Samir Fayed
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxMichelangelo van Dam
 
The Ring programming language version 1.9 book - Part 52 of 210
The Ring programming language version 1.9 book - Part 52 of 210The Ring programming language version 1.9 book - Part 52 of 210
The Ring programming language version 1.9 book - Part 52 of 210Mahmoud Samir Fayed
 
The Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryThe Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryChris Olbekson
 
Therapeutic refactoring
Therapeutic refactoringTherapeutic refactoring
Therapeutic refactoringkytrinyx
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsPierre MARTIN
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184Mahmoud Samir Fayed
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologyDaniel Knell
 

Was ist angesagt? (20)

Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 Talk: Unit TestingPython Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 Talk: Unit Testing
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Topological indices (t is) of the graphs to seek qsar models of proteins com...
Topological indices (t is) of the graphs  to seek qsar models of proteins com...Topological indices (t is) of the graphs  to seek qsar models of proteins com...
Topological indices (t is) of the graphs to seek qsar models of proteins com...
 
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
 
Object Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHPObject Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHP
 
Spock and Geb
Spock and GebSpock and Geb
Spock and Geb
 
Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design Patterns
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84
 
The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212
 
Django
DjangoDjango
Django
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
The Ring programming language version 1.9 book - Part 52 of 210
The Ring programming language version 1.9 book - Part 52 of 210The Ring programming language version 1.9 book - Part 52 of 210
The Ring programming language version 1.9 book - Part 52 of 210
 
The Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryThe Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the Query
 
Agile database access with CakePHP 3
Agile database access with CakePHP 3Agile database access with CakePHP 3
Agile database access with CakePHP 3
 
Therapeutic refactoring
Therapeutic refactoringTherapeutic refactoring
Therapeutic refactoring
 
Advanced Django
Advanced DjangoAdvanced Django
Advanced Django
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
 

Ähnlich wie Jython: Python para la plataforma Java (JRSL 09)

Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneRafael Felix da Silva
 
The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184Mahmoud Samir Fayed
 
Тестирование и Django
Тестирование и DjangoТестирование и Django
Тестирование и DjangoMoscowDjango
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185Mahmoud Samir Fayed
 
Pruebas unitarias con django
Pruebas unitarias con djangoPruebas unitarias con django
Pruebas unitarias con djangoTomás Henríquez
 
The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202Mahmoud Samir Fayed
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web developmentJohannes Brodwall
 
The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189Mahmoud Samir Fayed
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserHoward Lewis Ship
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4DEVCON
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Web осень 2012 лекция 6
Web осень 2012 лекция 6Web осень 2012 лекция 6
Web осень 2012 лекция 6Technopark
 

Ähnlich wie Jython: Python para la plataforma Java (JRSL 09) (20)

Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com Backbone
 
The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184
 
Scala on Your Phone
Scala on Your PhoneScala on Your Phone
Scala on Your Phone
 
Тестирование и Django
Тестирование и DjangoТестирование и Django
Тестирование и Django
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
droidparts
droidpartsdroidparts
droidparts
 
Django (Web Konferencia 2009)
Django (Web Konferencia 2009)Django (Web Konferencia 2009)
Django (Web Konferencia 2009)
 
The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185
 
Pruebas unitarias con django
Pruebas unitarias con djangoPruebas unitarias con django
Pruebas unitarias con django
 
The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
 
The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The Browser
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Web осень 2012 лекция 6
Web осень 2012 лекция 6Web осень 2012 лекция 6
Web осень 2012 лекция 6
 
Spsl vi unit final
Spsl vi unit finalSpsl vi unit final
Spsl vi unit final
 

Mehr von Leonardo Soto

El arte oscuro de estimar v3
El arte oscuro de estimar v3El arte oscuro de estimar v3
El arte oscuro de estimar v3Leonardo Soto
 
Una historia de ds ls en ruby
Una historia de ds ls en rubyUna historia de ds ls en ruby
Una historia de ds ls en rubyLeonardo Soto
 
El Lado Cool de Java
El Lado Cool de JavaEl Lado Cool de Java
El Lado Cool de JavaLeonardo Soto
 
Mi Arsenal de Testing en Rails
Mi Arsenal de Testing en RailsMi Arsenal de Testing en Rails
Mi Arsenal de Testing en RailsLeonardo Soto
 
Mapas en la web con Cloudmade
Mapas en la web con CloudmadeMapas en la web con Cloudmade
Mapas en la web con CloudmadeLeonardo Soto
 
Decent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivarsDecent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivarsLeonardo Soto
 
Sounds.gd lighting talk (RubyConf Uruguay)
Sounds.gd lighting talk (RubyConf Uruguay)Sounds.gd lighting talk (RubyConf Uruguay)
Sounds.gd lighting talk (RubyConf Uruguay)Leonardo Soto
 
Un tour por Java, Scala, Python, Ruby y Javascript
Un tour por Java, Scala, Python, Ruby y JavascriptUn tour por Java, Scala, Python, Ruby y Javascript
Un tour por Java, Scala, Python, Ruby y JavascriptLeonardo Soto
 
Lo que odiamos de la agilidad
Lo que odiamos de la agilidadLo que odiamos de la agilidad
Lo que odiamos de la agilidadLeonardo Soto
 
Javascript funcional
Javascript funcionalJavascript funcional
Javascript funcionalLeonardo Soto
 

Mehr von Leonardo Soto (20)

El arte oscuro de estimar v3
El arte oscuro de estimar v3El arte oscuro de estimar v3
El arte oscuro de estimar v3
 
Caching tips
Caching tipsCaching tips
Caching tips
 
Una historia de ds ls en ruby
Una historia de ds ls en rubyUna historia de ds ls en ruby
Una historia de ds ls en ruby
 
El Lado Cool de Java
El Lado Cool de JavaEl Lado Cool de Java
El Lado Cool de Java
 
Dos Años de Rails
Dos Años de RailsDos Años de Rails
Dos Años de Rails
 
Dos años de Rails
Dos años de RailsDos años de Rails
Dos años de Rails
 
Mi Arsenal de Testing en Rails
Mi Arsenal de Testing en RailsMi Arsenal de Testing en Rails
Mi Arsenal de Testing en Rails
 
Mapas en la web con Cloudmade
Mapas en la web con CloudmadeMapas en la web con Cloudmade
Mapas en la web con Cloudmade
 
Startechconf
StartechconfStartechconf
Startechconf
 
RabbitMQ
RabbitMQRabbitMQ
RabbitMQ
 
Decent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivarsDecent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivars
 
The Hashrocket Way
The Hashrocket WayThe Hashrocket Way
The Hashrocket Way
 
Sounds.gd lighting talk (RubyConf Uruguay)
Sounds.gd lighting talk (RubyConf Uruguay)Sounds.gd lighting talk (RubyConf Uruguay)
Sounds.gd lighting talk (RubyConf Uruguay)
 
Un tour por Java, Scala, Python, Ruby y Javascript
Un tour por Java, Scala, Python, Ruby y JavascriptUn tour por Java, Scala, Python, Ruby y Javascript
Un tour por Java, Scala, Python, Ruby y Javascript
 
Lo que odiamos de la agilidad
Lo que odiamos de la agilidadLo que odiamos de la agilidad
Lo que odiamos de la agilidad
 
Oss
OssOss
Oss
 
Javascript funcional
Javascript funcionalJavascript funcional
Javascript funcional
 
App Engine
App EngineApp Engine
App Engine
 
Introducción a Git
Introducción a GitIntroducción a Git
Introducción a Git
 
Tres Gemas De Ruby
Tres Gemas De RubyTres Gemas De Ruby
Tres Gemas De Ruby
 

Kürzlich hochgeladen

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
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
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
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
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
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
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
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
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
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
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
 
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
 
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
 

Kürzlich hochgeladen (20)

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
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
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
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
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
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
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
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
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
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
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...
 
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
 
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
 
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
 

Jython: Python para la plataforma Java (JRSL 09)

  • 1. Python para la Plataforma Java Leo Soto M. Jornadas Regionales del Software Libre 2009
  • 3. Python para la plataforma Java
  • 6. Plataforma Java con Java y Python, Ruby, Scala, Groovy...
  • 8. “Python is an experiment in how much freedom programmers need...”
  • 9. “...Too much freedom and nobody can read another's code; too little and expressiveness is endangered” - Guido van Rossum, 1996
  • 11. Jython Dinámico, flexible, extremadamente legible En una plataforma ubicua, sólida
  • 13. 1997
  • 14.
  • 15.
  • 16.
  • 17.
  • 19. Jython, 12 años después http://www.flickr.com/photos/digital-noise/3650559857/
  • 20. 2.5.1
  • 22. web2py etree nose setuptools virtualenv
  • 23. OK
  • 24. ¿Pero qué puedo hacer con Jython hoy?
  • 25. GUIs
  • 27. De Java a Jython
  • 28. final JFrame frame = new JFrame("HelloSwing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300,300);
  • 30. frame = JFrame("HelloSwing", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(300, 300))
  • 31. Container content = frame.getContentPane(); content.setLayout(new FlowLayout());
  • 34. JButton botonSaludar = new JButton("Saludar"); JButton botonDespedir = new JButton("Despedirse"); botonSaludar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(frame, "Hola!"); } }); botonDespedir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(frame, "Chao!"); frame.dispose(); } }); content.add(botonSaludar); content.add(botonDespedir);
  • 35. def saludar(event): JOptionPane.showMessageDialog(frame, "Hola!") def despedir(event): JOptionPane.showMessageDialog(frame, "Chao!") frame.dispose() content.add(JButton("Saludar", actionPerformed=saludar)) content.add(JButton("Despedirse", actionPerformed=despedir))
  • 36. Otra demo con Swing (Si es que tenemos acceso a internet)
  • 38. Web
  • 40. Y sólo por diversión...
  • 41. ### View #!/usr/bin/env python from django import http """ from django.template import Template, Context WSW - the World's Shittiest Wiki. """ def wsw(request, title): import re title = urllib.unquote_plus(title) if title else "Home" import urllib p, created = Page.objects.get_or_create(title=title) from django.conf import settings form = PageForm(instance=p) if request.method == "POST": ### Config form = PageForm(request.POST, instance=p) settings.configure( form.save() DEBUG = True, return http.HttpResponseRedirect(request.get_full_path()) DATABASE_ENGINE = "doj.backends.zxjdbc.postgresql", else: DATABASE_NAME = "wsw", form = PageForm(instance=p) DATABASE_USER = "wsw", t = Template("""<h1>{{ p.title }}</h1><ul>{% for p in DATABASE_PASSWORD = "wsw", allpages %}<li><a href="{{ p }}">{{ p }}</a></li>{% endfor %} ROOT_URLCONF = __name__) </ul><form action="{{ request.get_full_path }}" method="POST"> <p>{{ form.content }}</p><input type="submit"></form>""") ### Model wikiwords = re.findall( from django.db import models '[A-Z][a-z]+[A-Z][a-z]+(?:[A-Z][a-z]+)*', p.content) allpages = [ class Page(models.Model): page.title for page in Page.objects.order_by('title')] title = models.CharField(max_length=300, allpages.extend( primary_key=True) word for word in wikiwords if word not in allpages) content = models.TextField() return http.HttpResponse(t.render(Context(locals()))) class Meta: ### Main app_label = "wsw" if __name__ == '__main__': from django.core import management ### URLs from django.db import connection from django.conf.urls.defaults import * from django.core.management.color import no_style cursor = connection.cursor() urlpatterns = patterns(__name__, ('(.*)', 'wsw')) statements, _ = connection.creation.sql_create_model( Page, no_style()) ### Form try: from django.forms import ModelForm for sql in statements: cursor.execute(sql) class PageForm(ModelForm): connection.connection.commit() class Meta: except: model = Page pass fields = ['content'] management.call_command('runserver')
  • 43. Testing http://www.flickr.com/photos/emotionaltoothpaste/26034597/
  • 45. def factorial(n): It must also not be ridiculously large: """Return the factorial of n, an >>> factorial(1e100) exact integer >= 0. Traceback (most recent call last): ... If the result is small enough to OverflowError: n too large fit in an int, return an int. """ Else return a long. import math >>> [factorial(n) if not n >= 0: ... for n in range(6)] raise ValueError("n must be >= 0") [1, 1, 2, 6, 24, 120] if math.floor(n) != n: >>> [factorial(long(n)) raise ValueError( ... for n in range(6)] "n must be exact integer") [1, 1, 2, 6, 24, 120] if n+1 == n: # catch a value like 1e300 >>> factorial(30) raise OverflowError("n too large") 265252859812191058636308480000000L result = 1 >>> factorial(30L) factor = 2 265252859812191058636308480000000L while factor <= n: >>> factorial(-1) result *= factor Traceback (most recent call last): factor += 1 ... return result ValueError: n must be >= 0 Factorials of floats are OK, but the float must be an exact integer: >>> factorial(30.1) Traceback (most recent call last): ... ValueError: n must be exact integer >>> factorial(30.0) 265252859812191058636308480000000L
  • 46. Demo de (ab)uso de DocTest
  • 47.
  • 48.
  • 49. ¿Por cierto, quien más usa Jython?
  • 50.
  • 51.
  • 52.
  • 55. ¿Y dónde puedo aprender más?
  • 57. ¿Preguntas? Contacto: @leosoto http://blog.leosoto.com
  • 58. ¡Gracias! Contacto: @leosoto http://blog.leosoto.com