5 ms·
For an even easier-to-remember alternative, there’s q: https://github.com/zestyping/q https://github.com/zestyping/q All you need is `import q`. q works like a
by nneonneo 6y ago
For an even easier-to-remember alternative, there’s q: https://github.com/zestyping/q https://github.com/zestyping/q
All you need is `import q`. q works like a function (q(x)), like a variable (q|x and q/x, so you get different operator precedences) and like a decorator (@q), so it can be used in practically any circumstance for a quick debug print. Plus, the name sounds like you’re interrogating something.
- zestyping 6y agoI was wondering whether someone would notice that it's a clone of q! Thanks! :) q has the additional feature that you can decorate any function or method with `@q`, which causes invocations to be logged with arguments, return values, and exceptions. Really handy for tracing what's happening in your program.
- canada_dry 6y agoA quick look at the intro page was a bit disappointing. You immediately get how ic works because their examples include the code and result.
- josalhor 6y agoThis is actually really cool. I was going to say that so many people miss the point of print debugging and as a consequence forget to shorten the import line as much as possible. from icecream import ic;ic() is 28 characters import q;q() is 12 characters print() is 7 characters
- oauea 6y agoWhy would the amount of characters possibly matter?
- josalhor 6y agoI find it important because it lowers the barrier of entry to print debugging. I have found myself using less prints in Java than in Python both because of static typing and having to write the full `System.out.println`. This is also important to me because I am very cautious of not doing a file-level import (I don't want to commit a file with the dependency). The fewer characters it takes, the easier it is for me to write it all in a single line and remove it afterward.
- canada_dry 6y agobc pgmrs r lazy af. Seriously though... when I'm in debugging mode, speed and efficiency in completing the task is paramount. So, every character I save typing, the better!
- kyawzazaw 6y agoreduce the energy barrier to debugging
- Noumenon72 6y agoThe article says you can call from icecream import install install() in main, and from then on icecream counts as a built-in, so you can just say ic(). Four characters.