A few weeks ago, i had to grade the exercises that the students had delivered in Java 2 course (in Greek). The students had to deliver a robocode agent that would implement the basic functionality of an agent (enemy tracking, shooting, moving and avoiding any hostiles) and be also antagonistic with a few sample agents that are distributed with the system.

The exercises were three (3), and in each exercise they should have delivered the source code ziped and a jar with the compiled code.

I had the students registry numbers / names / teams (they were organised in team of 1-3 persons) and a list of delivered assignments, and i had to do the following: I tried and automated the first task with a python script, which scanned all the the submitted files, parsed the filename and produced a template list, that i could import in an spreadsheet program and calculate the final grade.

The filename already contained the team number, deliverable number, and the registry number (of the student that submitted it), for example 2007A_2_8060035_1_source-2.zip. I parsed the filename with a simple regex 2007A_([0-9]+)_([0-9]+)_(1|2|3)_.*\\.(zip|jar|rar). The rest of it is really simple, create class instances containing the information regarding the students and the exercises and finally export the data to the template list.

Then something unexpected (at least for me ... the n00b) happened. The data produced by the first part of the program, could not be accessed correctly by the second (see the source code comments). I added a few print out line in the middle of the process and all where in place. What had happened?

The answer was really simple. Me, the Java man ... was really get used on strict type systems, and now forget that python resolves the types dynamically, and the key of the teams dictionary was really a string, not an integer that i used back then in the second part. Doh! It took me 30 mins to solve the mystery, and i finally realized the difference between the 1 and "1".