PyCon Brasil is a success!

That’s right. The first brazilian Python conference, which happened last week in Unicamp, was an enormous success. Even thought I had no doubt it would be an interesting event, I got surprised to see the excellent level of the talks and the public attending the event. There were about one hundred people from all around the country, who enthusiastically observed the following topics in these two days (a rough resume):

  • Python in web management (zope, zope3, cmf, plone)
  • Python in calculus and engineering (scipy, numarray)
  • Python in biology: analysis, sequence edition, molecular alignment
  • Python in game programming (pygame)
  • Python in constraint solving problems
  • RAD in Python (pygtk, gazpacho, boa)
  • Python in graphics (gimp-python)
  • Python in education
  • The brazilian Python community
  • Python in commercial management (stoq)

For me, it was a great opportunity to meet personally many of the brazilian pythoneers I didn’t know personally, like Xiru, Sidnei da Silva, Johan Dahlin (not yet brazilian, but becoming one ;-), Rodrigo Senra, and others. It was also a great way to meet many good active pythonists I didn’t had previous contact with, and see in what ways Python is being used in several different areas.

Most of the talks were taped, and will soon be freely available somewhere (more on this later).

Thanks a lot to Rodrigo Senra and the rest of the Unicamp people who provided the space and organized the event!

Posted in Conference, Python | 3 Comments

Textual watermarks with Python Imaging Library

I’ve added a new snippet about doing watermarks with PIL.

Posted in Python, Snippet | 2 Comments

Article and discussions about Smart

FedoraNEWS has a nice article about Smart, posted by Xanax.

FedoraForum also has a thread about it, as Ian MacGregor notified me.

Posted in Project | 6 Comments

Decorator for automatic inclusion of function definition in __doc__

Python 2.4 included support for function decorators. Decorators are callable objects that may modify a given function or class method arbitrarily when they’re prepended with specific syntax to the function/method definition.

The following code implements a decorator that will automatically include the arguments accepted by a given function in its own documentation:

import inspect
def argspec(object):
    spec = inspect.formatargspec(*inspect.getargspec(object))
    if object.__doc__:
        object.__doc__ = "%s%snn%s" % (object.__name__, spec, object.__doc__)
    else:
        object.__doc__ = "%s%s" % (object.__name__, spec)
    return object

It may be used as follows:

>>> @argspec
... def test(a,b=1,*c,**d):
...     """My test function"""
...
>>> print test.__doc__
test(a, b=1, *c, **d)

My test function

Notice that this is interesting mostly for hacking value. Most softwares that generate documentation for Python code, like the standard pydoc module, already take care of building and showing that information.

Posted in Python, Snippet | Leave a comment

Problem of the Week at University of Massachusetts

University of Massachusetts has a very nice Problem of the Week service where they post a new math related problem every monday. At that time they report the percentage of people that correctly answered the question as well. To submit an answer, check the rules page. They’re usually very quick at answering if a given solution is correct or not.

This week’s problem is not specially challenging though. The problem name is Turn the page, and consists of the following question:

A novel has 527 pages (pages 1 – 527). How many digits will it take to number all 527 pages from 1 to 527?

How many people wouldn’t know how to solve that? Solving with eyes closed is kind of fun, but with help from a calculator or from any programming language it’s trivial. In python, that single line does the job:

sum([len(str(i)) for i in range(1,527+1)])

Let’s hope for a more interesting problem next week. There are some good problems from previous weeks available as well.

Posted in Math, Puzzle, Python | Leave a comment

Petals Around the Rose

Petals Around the Rose is an interesting brain teaser. Here is a copy of the game description:

The name of the game is Petals Around the Rose. The name of the game is important. The computer will roll five dice and ask you to guess the score for the roll. The score will always be zero or an even number. Your mission is to work out how the computer calculates the score and become a Potentate of the Rose.

Simple and challenging.

Posted in Puzzle | Leave a comment

All combinations of N elements

Here’s a snippet to compute all combinations of N elements over K positions.

Posted in Math, Python, Snippet | 3 Comments

Permutations of all subsets

Another snippet to compute the permutations of all subsets.

Posted in Math, Python, Snippet | 3 Comments

Permutations and derangements

Two snippets to compute permuatations and derangements in Python.

Posted in Math, Python, Snippet | 4 Comments

Rik van Riel talks about Smart at Umeet 2004

Thanks for the nice words in your presentation Rik!

Posted in Conference, Project | Leave a comment