python

Capturing a screen image with python and PIL on Windows

Submitted by fabio on Tue, 2009-03-17 12:11.

The more I use Python, the more I love it.

This programming language is simply awesome: with it's simple api and the huge amount of freely available additional modules creating complex applications is really easy and fast.

For example less than 15 minutes ago I wondered: how can I capture an image of the computer screen using Python?

If you don't know Python you might think that this could be pretty a complex task.

A simple django basename template filter tag

Last updated on Thu, 2009-04-16 13:52. Originally submitted by fabio on 2008-08-29 12:42.

I'm using Django, a python coded framework to develop web applications, to implement a project for the University.

During the development I needed to have a template tag which, given a path to a file, just returns its basename (just as it do the python os.path.basename).

So I implemented it. Following you have the code for it.

Python: call a function with more arguments on each element of a list

Last updated on Fri, 2008-06-27 18:12. Originally submitted by fabio on 2008-06-25 12:13.

I'm recently working a lot with Python because I understood it perfectly fits my needs being powerful, clean and fast to develop with it.

If you program with it there are good chances that you will end up using lot of lists which are pretty well designed and powerful in Python.

A really useful function in Python is map() which let you execute one function on each element of a list:

L = [0.1, 0.4, 0.7]
L2 = map(round, L)
print L2

#output [0.0, 0.0, 1.0]

Serial RS232 connections in Python

Submitted by fabio on Thu, 2008-05-08 14:18.

Here at ULPGC I'm following a Robotics course. In the practical part of the exam we have to write some applications to operating some didactics robots we have (Rhino XR-4 and SCARA Robots).

Each robot is connected to a Controller (Rhino Mark-4) which can be connected to a PC to send commands to the Controller in order to let the robots do things.

The PC to Controller connection is a serial RS-232 connection.

Sudoku resolver in Python

Last updated on Fri, 2007-12-14 12:45. Originally submitted by fabio on 2007-12-08 15:15.

A simple Sudoku resolver written in Python.

Sorry for the Italian code comments. Please add a comment below if you don't get parts of the algorithm.