16.11.2014 Views

callback patterns and idioms in Python

callback patterns and idioms in Python

callback patterns and idioms in Python

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tim<strong>in</strong>g <strong>and</strong> debugg<strong>in</strong>g<br />

timeit.Timer(stmt, setup)<br />

*str<strong>in</strong>g* arguments to compile & execute<br />

a dynamic-language twist on <strong>callback</strong>!-)<br />

"event" for <strong>callback</strong>:<br />

setup: once, before anyth<strong>in</strong>g else<br />

stmt: many times, for tim<strong>in</strong>g<br />

the pdb debugger module lets you use<br />

either str<strong>in</strong>gs or callables...:<br />

pdb.run <strong>and</strong> .runeval: str<strong>in</strong>gs<br />

pdb.runcall: callable, arguments<br />

22

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!