SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

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

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

Más de 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
 

Más de 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
 

Último

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

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