[pyar] Hello world

Matías Pruvost matiaspruvost en gmail.com
Jue Oct 31 22:28:14 ART 2013


Hola,

Les escribo porque me suscribí a la lista y no quería dejar pasar el paso 2
de las instrucciones para suscribirse. Aquí les dejo mi sencillo Hola
Mundo. Espero que se diviertan tanto como yo mientras lo hice.

Para el que quiera probar el Hola mundo, debe correr el script y pasarle el
path.
Ejemplo: python hello.py pages.png
Y a descubrir el mensaje!
*
*
Estoy aprendiendo python mientras aprendo a programar, toda sugerencia es
muy bien recibida.

Quiero felicitar calurosamente a los organizadores de la PyConAr 2013, el
evento estuvo genial, aprendí un montón.

Muchos saludos,
Mati.

-- 
*Matías Germán Pruvost*
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20131031/faf04cf9/attachment-0001.html>
------------ próxima parte ------------
import sys
import Image


class Message(object):
    def __init__(self, path):
        self.image = Image.open(path)
        self.width, self.height = self.image.size
        self.pixels_n = self.width*self.height

    def _get_fibonacci(self, n):
        a, b = 0, 1
        serie = []
        while b < n:
            a, b = b, a+b
            serie.append(b)
        return serie

    def _position(self, i):
        column = i//self.width
        files = i%self.width
        rgb = self.image.convert('RGB')
        return rgb.getpixel((files,column))

    def sherlock_hangzhou (self):
        numbers = self._get_fibonacci(self.pixels_n)
        look_for = []
        for pixel in range(self.pixels_n):
            for number in numbers:
                if pixel == number:
                    look_for.append(self._position(number))
        return look_for

if __name__ == "__main__":
    message = Message(sys.argv[1])
    look_for = message.sherlock_hangzhou()
    for word_message in look_for:
        book_page, page_word, _ = word_message
        print (repr(book_page).rjust(4), repr(page_word).rjust(4))
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: pages.png
Type: image/png
Size: 34287 bytes
Desc: no disponible
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20131031/faf04cf9/attachment-0001.png>


More information about the pyar mailing list