Skip to content
/ q Public
forked from zestyping/q

Quick and dirty debugging output for tired programmers.

License

Notifications You must be signed in to change notification settings

xsteve/q

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

q

Code Shelter Build Status

Quick and dirty debugging output for tired programmers.

For a short demo, watch the Lightning Talk from PyCon 2013.

Install q with pip install -U q.

All output goes to /tmp/q (or on Windows, to $HOME/tmp/q). You can watch the output with this shell command while your program is running:

tail -f /tmp/q

To print the value of foo, insert this into your program:

import q; q(foo)

To print the value of something in the middle of an expression, you can wrap it with q(). You can also insert q/ or q| into the expression; q/ binds tightly whereas q| binds loosely. For example, given this statement:

file.write(prefix + (sep or '').join(items))

you can print out various values without using any temporary variables:

file.write(prefix + q(sep or '').join(items))  # prints (sep or '')
file.write(q/prefix + (sep or '').join(items))  # prints prefix
file.write(q|prefix + (sep or '').join(items))  # prints the arg to write

To trace a function (showing its arguments, return value, and running time), insert this above the def:

import q
@q

To start an interactive console at any point in your code, call q.d():

import q; q.d()

Other projects inspired by this one

About

Quick and dirty debugging output for tired programmers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 96.9%
  • Makefile 3.1%