I See Dead Code

… as sounding brass, or a tinkling cymbal.

I See Dead Code header image 4

Entries Tagged as 'python'

Breaking Event Cycles

July 12th, 2009 · No Comments

A recurring problem in (not only) GUI programming are event cycles, i.e. the receiving of events oneself has triggered. These can quickly lead to event cycles, where change triggers change triggers change, until something gives out—usually the stack.
A particularly cheap way of breaking cycles are simple boolean flags:

class Foo(object):
listen = True
[...]

[Read more →]

Tags: python

Scrollable Widgets with PyGTK

May 17th, 2009 · No Comments

It is possible to write custom GTK widgets that have “native” scrolling support, as opposed to just shoving them into a GtkViewPort and forgetting about them.
Apart from having mastered a small coding challenge, as it turned out to be, this also gives you greater control over the scrolling itself, like making sure that certain [...]

[Read more →]

Tags: lang:en · programming · python

I have no life and I must program

May 31st, 2008 · No Comments

Some participants of this semester’s „Computational Linguistics” course (which is a code word for „10 different lecturers guide you through the wonderful world of algorithms and theoretical foundations of CoLi”) obviously lack a life and willfully extended their own homework assignment, writing small toolkits for finite state automata.
Surprisingly, all those toolkits were written in Python [...]

[Read more →]

Tags: coli · lang:en · programming · python

Look at me, I know Functional Programming!

May 5th, 2008 · 1 Comment

Sometimes I wonder what the hell I might have been thinking while writing code like this1 :

1
2
3
4
5
6
7
def uncurry(f):
return lambda t: f(*t)
 
def longest_common_prefix(Sa, Sb):
return len(list(
takewhile(uncurry(eq),
[...]

[Read more →]

Tags: lang:en · programming · python

Random Python unittesting snippet #1

December 18th, 2007 · No Comments

A small context manager for stating assertions about exceptions in Python unit tests:

@contextmanager
def assert_raises(*exc_types):
"""A context to ensure that an exception of a given type is thrown.
 
Instead of
 
@nose.tools.raises(ValueError)
def test_that_raises():
# … lengthy setup
[...]

[Read more →]

Tags: lang:en · programming · python

Stockholm TreeAligner 0.8 „Gamla Stan” released

December 13th, 2007 · No Comments

It’s only a couple of months late, but we’ve just released a new version of the Stockholm TreeAligner to an awed audience. This release features the prototype implementations of TIGERSearch and alignment queries, which will be perfected in the next release, due in March 2008.
For those who are wondering what kind of code name Gamla [...]

[Read more →]

Tags: coli · lang:en · programming · python · treealigner

Truth itself

December 8th, 2007 · No Comments

As is the way with Python, it turns out that you can create the start of something useful in less that fifty lines of code.↪
I simply cannot confirm often enough how true that is.

[Read more →]

Tags: lang:en · python

TLT 2007

December 6th, 2007 · No Comments

Es ist soweit, und die ganze Welt der Baumdatenbanken bekommt einen Geschmack vom Stockholm TreeAligner. Joakim wird morgen ein Poster über das „Gamla Stan”-Release von STA präsentieren (Paper).
Nachdem das Release nur ein paar Monate verspätet war, machen wir uns auch gerade daran, die technische Basis mit ein paar gezielten geradezurücken. Die Hauptattraktionen für das nächste [...]

[Read more →]

Tags: coli · lang:de · projects · python

I have two cores, where’s my free lunch?

August 26th, 2007 · No Comments

I have tried to optimize the TigerXML parser in STA [↪] a bit, the results (graphs are stored in memory, with a 55 MiB corpus, on my Core 2 Duo 2.2GHz):

unoptimized: 61.01s
optimized: 39.68s

That still seemed a bit too slow to me, and I decided to try out some parallelization: since the ID reference remapping and [...]

[Read more →]

Tags: lang:en · programming · python · tech

Verweichlicht…

August 16th, 2007 · No Comments

Die IDE an sich
Nach einem Jahr verschärftem Toolmonkeyism auf der Arbeit bin ich zu der Überzeugung gelangt, dass auch beim Python-Programmieren ein wenig IDE-Unterstützung nicht schlecht wäre. Eclipse (besonders das erstaunlich stabile 3.3) wächst einem dann doch ans Herz. Nicht dass ich für Python unbedingt Ctrl-1 bräuchte (z.b. den infernalischen Java-Typinferenz-Hack, Variablen ohne Typ zu [...]

[Read more →]

Tags: lang:de · programming · python · tech