20 ms·
Icecream: Never use print() to debug again in Python
- yuribro 6y agoThis is similar to an earlier package called "q"[0] [0] https://github.com/zestyping/q https://github.com/zestyping/q
- dkdk8283 6y agoPretty neat. Seems better than print.
- qwerty456127 6y ago> prints both its own arguments and the values of those arguments. That's not enough. Almost always I also want the argument type. Occasionally a unique (i.e. as precise as possible) sortable (i.e. with leading zeros) time stamp also comes useful.
- qwerty456127 6y ago> sortable (i.e. with leading zeros) time stamp Not just with leading zeros but also written in the YYYY-MM-DD-HH-... format.
- grun 6y agoThis would be great to have. I don't use types in my Python much. Yet at least. Can you submit a PR to add this? That'd be awesome.
- deleted 6y ago[deleted]
- myaccount80 6y agoNice. Right now I’m using the following: print(f’{foo(123)=}’) Which prints: foo(123)=‘result’
- altitudinous 6y agoI am always going to use print to debug in every programming language I can until the day I die.
- konschubert 6y agoI have found that print-style debugging gives a good birds-eye view of the situation. With a stepping debugger, I tend to get lost in the weeds. My suspicion is that the bug fixes I come up with are less holistic when using a debugger.
- space_rock 6y agoActually rust has the functionality of Icecream as a buildin command "dgb" and you quickly find yourself using it over print
- huhtenberg 6y agoNo doubt blatantly ripped off the venerable print_r :P
- masklinn 6y agoNope, because unlike print_r dbg! returns the input as-is, so you should be able to wrap any expression in dbg! in-place, and just get debug output. According to the RFC, the direct inspiration for dbg! is Haskell's traceShowId (http://hackage.haskell.org/package/base-4.10.1.0/docs/Debug-Trace.html#v:traceShowId http://hackage.haskell.org/package/base-4.10.1.0/docs/Debug-...).
- threatofrain 6y agoAnd Julia with @show.
- QuesnayJr 6y agoI had this exact thought, but the title gives the wrong impression (at least to me). The package just defines a fancy print.
- kissgyorgy 6y agoYou can do the same thing with Python 3.8+ by using f-strings and just appending "=" to the variable name: >>> print(f"{d['key'][1]=}") d['key'][1]='one'
- grenoire 6y agoWHAT... Why ain't anybody talking about this? Brilliant!
- JetAlone 6y agoIn this case, it would seem it took a little reinvention in order to let the wheel's discovery be known.
- willyt 6y agoNot used it, but ic seems to be compatible back to python 2.7 so not really comparable. I can't use the builtin thing in my python code because the host software for my plugins is running python 3.6 embedded and only recently upgraded from 3.3 in the latest release so if I want to maintain backwards compatibility I can never use the new python builtin. I expect lots of other people are in the same position.
- JetAlone 6y agoYeah you're right. I hadn't realized it was so new till a little later... Well, it's good that IC has a stronger use case surface area for those who want it.
- wadkar 6y agoIt was “recently” introduced in Python 3.8. See sibling for link to issue tracker
- neumann 6y agoWait. How does this work?
- atoav 6y agoI am sorry, but I am not going to pull in an external dependency just for this, especially not with the power of fstrings in newer python versions.
- mnd999 6y agoIndeed, in a couple of years this is the new leftpad.
- dataflow 6y agoIt's for debugging. Not something to depend on in released code. Put the import in your site initialization file and you won't even have to import it in the REPL.
- atoav 6y agoI understand, but Python >3.8 can do this: >>> x = 1+1 >>> print(f"{x = }") x = 2 And if it is included why pulling in a dependency? And even if it is a dev dependency: it can be a dev dependency that bites you in two years in the middle of a night when your service fails.
- tamentis 6y agoYou're just being difficult. It's easy, you just setup these 10 Node.js micro services in docker, setup your database, the cache. Then my friend, you can really debug with beautiful print messages. Wait until someone creates a $10/user SaaS service out of it.
- fouc 6y agoInsightful prediction of how development will be done in the future.
- deleted 6y ago[deleted]
- mcswell 6y agoAnd I am going to use it, because of the pain of typing {, which half the time my fingers miss (whereas I'm pretty good at typing 'i' and 'c').
- nneonneo 6y agoFor 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.
- Justsignedup 6y agolots of nay saying here... i for one like this. sure there are some ways in the new python code to handle some of the features of ic, but the overall feature set is rather nice. sure it isn't a debugger, but definitely better than prints.
- mikkelam 6y agoWhy don't people just use a debugger? It boggles my mind that people live with print style debugging. Depending on the project, it can be such a timer waster and just plainly worse in all aspects. Especially in Pycharm for me, it is incredibly easy. Even when running over ssh in remote computers I can use my debugger.
- extrememacaroni 6y agouncle bob told me you don't wanna be good at using a debugger print("here") till the day i die!!!
- CodeGlitch 6y agoI find you need both. Print gives you a nice high level view of your code, whilst stepping let's you see what's happening. I would say I get more use out of printing these days.
- chpmrc 6y agoWhat do you use for remote debugging? And do you run all production instances with a debugging server attached? What's the overhead?
- mikkelam 6y agoI use Pycharm's native ssh interpreter toolhttps://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html https://www.jetbrains.com/help/pycharm/configuring-remote-in... It automatically syncs your local project with the remote machine and runs seamlessly. They have a similar offering for docker, but I have yet to try it when running over ssh.
- globular-toast 6y agoFor me it's just lack of practice. This is rare enough for me that I would have to look up how to use the debugger each time. I never forget how to type print.
- dataflow 6y agoThey're not perfect substitutes for each other. And not every python script that you need to quickly debug is worth firing up a while IDE for. Especially if your IDE requires creating a project and such. I say this as someone who very much loves Visual Studio.
- lihaoyi 6y agoWe have this in Scala via the PPrint library, which provides 'pprint.log'. pprint.log also shows the filename/line number (so you can find your prints later) and has colored output and intelligent indent-formatting for things than wrap to multiple lines. It's super covenient!
- dzamlo 6y agoIf.uou use vscode, the [Puke-Debug](https://marketplace.visualstudio.com/items?itemName=Zorvalt.puke-debug https://marketplace.visualstudio.com/items?itemName=Zorvalt....) extension is a nice alternative. It allows to easily insert and remove similar print statements, in multiple languages, without adding a dependencies to your project that you need to remove afterwards.
- zxteloiv 6y agopretty print is not important for me when debugging or logging, only would it make sense if the neat logger/debugger could accept a lazily evaluated expression. That saves some time if the logger is disabled at runtime. Otherwise the ugly print-debug-fix-and-remove pipeline is still there.
- makach 6y agosometimes, all you need is a print() statement
- pantulis 6y agoAs a staunch defender of print-based debugging I guess this would be a lot more useful if this could be connected to a logging library.
- stuntcoder 6y agoI promise the 15 minutes it takes to learn to use the debugger will save years of your life
- atakan_gurkan 6y agoWhich debugger would you recommend?
- dbrgn 6y agoFor Python: ipdb. In your code, you can just drop in "import ipdb; ipdb.set_trace()" and the execution will stop there with an interactive prompt. Alternatively start the script through (i)pdb and set breakpoints. You can also use plain pdb ("import pdb; pdb.set_trace()"), which has the advantage that it comes with the Python stdlib, but the interactive prompt is less fancy (no history, no autocompletion, etc).
- gcarvalho 6y agoAdd `export PYTHONBREAKPOINT=ipdb.set_trace` to your .bashrc and "breakpoint()" will invoke ipdb by default.
- dbrgn 6y agoThat is a great trick, thank you!
- the_cat_kittles 6y agoi use this frequently! but print() is still handy and my go to
- gjulianm 6y agoNot necessarily. I know very well how to use a debugger, but nowadays I just prefer to use prints: it forces to you actually think about what's happening instead of just looking at it. It's also more useful in situations where putting a debugger actually changes behavior (high performance systems, parallel programs).
- andix 6y agoJust don‘t use print for debugging! Either add meaningful and logging to your software (which also other technical people can use). Or just use a debugger and breakpoints.
- pjmlp 6y agoI just use debug trace points. https://docs.microsoft.com/en-us/visualstudio/python/debugging-python-in-visual-studio?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/python/debuggi...
- scolvin 6y agoHumm, I built a similar but more powerful tool: https://github.com/samuelcolvin/python-devtools https://github.com/samuelcolvin/python-devtools (install with `pip install devtools`) It has similar functionality for debugging but has prettier formatting and code highlighting using pygments.
- scolvin 6y agoOne of the most useful trick I found was installing the tool via sitecustomize.py so you don't need the import: # add devtools debug to builtins try: from devtools import debug except ImportError: pass else: __builtins__['debug'] = debug (see https://github.com/samuelcolvin/python-devtools#usage-without-import https://github.com/samuelcolvin/python-devtools#usage-withou...) This would work with icecream too. The second advantage of not needing the import is that CI fails if you forget to remove all debug() commands.
- deleted 6y ago[deleted]
- kleiba 6y agoInstead of introducing a new library, why not just instruct your editor to do the heavy lifting for you? For instance, I've written a small Emacs function that asks for the argument to print in the Minibuffer and then inserts it once quoted, once unquoted. It's quite nice to have such a function for any programming language you use and bind it to the same keyboard short-cut.
- albertzeyer 6y agoIf you like this, you might also like my small debugging utility, a better_exchook replacement: https://github.com/albertz/py_better_exchook https://github.com/albertz/py_better_exchook Simple example: assert x == 4 When this fails, it will print the value of `x`.
- zomglings 6y agoJust a point of curiosity about reassigning `sys.excepthook`. Is there a reason you simply reassign it and lose information about the old excepthook: sys.excepthook = better_exchook instead of something like: def generate_better_exchook(..., current_excepthook=None): previous_excepthook = current_excepthook def better_exchook(exception_type, exception_instance, exception_traceback): ... if previous_excepthook is not None: previous_excepthook(exception_type, exception_instance, exception_traceback) return better_exchook and then sys.excepthook = generate_better_excepthook(..., sys.excepthook) Do you prefer not to do this because it would keep this closure around in memory until the Python process exits?
- albertzeyer 6y agoHey, sorry, just saw this question right now. Actually, I don't know. I assume this is not standard, because many excepthook handlers would probably print some variant of the stack trace on stdout or stderr, and then you would end up having printed the stack trace multiple times. Or maybe it depends. If your excepthook instead prints it somewhere else (e.g. some log file), it makes sense to also call the default handler afterwards. But no, this is not about the closure.
- polm23 6y agoPreviously: (2019) https://news.ycombinator.com/item?id=19867460 https://news.ycombinator.com/item?id=19867460 (2018) https://news.ycombinator.com/item?id=16377714 https://news.ycombinator.com/item?id=16377714
- submeta 6y agoThis here is excellent: print(f"{d['key'][1]=}") d['key'][1]='one' My immediate reaction was: How can I make this `form` easier to type. And that's what `Iceacream` does. Reviewed their code and realized they work with AST and inspection. I recently started to learn (Common )Lisp. I realize how easy it would be to write a macro in Lisp that would implement the functionality of `Iceacream`, in a few lines of code.
- dbalan 6y agoThis is a really nice tool. But the fundamental reason most go for print is because its right there and that wins over other UX improvements or machinery. Python is a language where you can get a reasonably good debugger with a single line almost anywhere, still people reach for print()
- belorn 6y agoI am looking at the examples (and the comments here about f-strings), but neither fit my own usage of debugging with print. When I use print, it is mostly for two reasons. To see the structure of a dict (often with multiple layers of dicts inside), or to get dir(x) to see what methods and attributes of a library object, since the documentation is not always so forthcoming.
- petr25102018 6y agoA while back I made a list of the Python debugging tools: https://stribny.name/blog/2019/06/debugging-python-programs/ https://stribny.name/blog/2019/06/debugging-python-programs/
- grun 6y agoYou should add IceCream!
- kalipso 6y agowait isnt that just enforcing bad practice? doesnt python have proper debuggers with breakpoints ect? why in hell should i use a lib to print stuff just for debugging? i mean why not having a proper logging lib and pipe some statements to [debug] or whatever i dont get it.
- kevincox 6y agoRequirements for logging and debugging are quite different. For logging I probably don't want to print the source expression, I probably want to include a semantic description. For logging it is also intended to live in the code for longer, so I probably want something a touch more readable. The debugging and logging spaces overlap but there are definitely differences if you really start optimizing for debugging experience. I don't think encouraging bad practices is a problem if the code will be deleted before being submitted.
- kalipso 6y agoYou are right with some points but i still see it a bit different. I disagree with the statement "I don't think encouraging bad practices is a problem if the code will be deleted before being submitted.". The thing is the deadline just needs to be shifted a bit and suddenly you have to commit code in a hurry. There will always be the chance that you forget delete something. A great example is this one: https://arstechnica.com/gadgets/2021/03/buffer-overruns-license-violations-and-bad-code-freebsd-13s-close-call/ https://arstechnica.com/gadgets/2021/03/buffer-overruns-lice... low level code with debugging printfs nearly made it into the freebsd kernel. I mean everyone prints something for debugging purpouse from time to time, thats fine. but having a lib extra for that. i dont think thats a good idea. Logging frameworks also enable toggling if source expression is printed or not. So you can only show it if you give a --debug flag to your tool for example.
- mastrsushi 6y agoYou can also use a modern IDE debugger like Visual Studio. It gives you quicker results and lets you change values at runtime. Instead of print debugging like it's 1978. Of course then you can't brag to your friends about using Vim or Emacs ;)
- robsws 6y agoThis looks cool and all, but why is it called Icecream? I know naming abstract stuff is hard but it feels like this lends itself to a more descriptive name. "ic()" tells me nothing about what the function does.
- NateEag 6y agoI think it's a (confusing) two-layer pun. When read phonetically as letter names, the name "ic" sounds like "I see". "ic" also is an initialism for "ice cream". Everyone loves ice cream, and so another low-meaning cutesy-poo pun-ishment of a name was born. I think. Pure speculation here.
- alternatetwo 6y agoMy first thought was "I scream" ...
- grun 6y agoBingo. All the one letter PyPi project names were taken.
- Igelau 6y agoAt its core, it has always called inspect.currentframe(). I suspect the first iteration was a wrapper around inspect.currentframe(), abbreviated as ic(), which was then backronym'd into ice cream.
- mybrid 6y agoParty on! I applaud this effort. As a UI/UX engineer I can say that there is no one debugging UI/UX experience to fit all. Of course there is the active/passive division between active debugging and logging. There are further usability divisions in both of those. As this is a passive/logging debugging scheme I'm sure there are those in the passive debugging community who will find this helpful, if not vocal.There is no one size fits all when it comes to usability although 99.9999% of software built only presents one usability experience and only begrudgingly provide the disabled community access as an after thought. A fairly significant percentage of the population is color blind and yet web sites still overly rely on red. Yby. You be you. The bane of all usability is one size fits all. Well met! We need more, not less, usability options.
- StavrosK 6y agoThe split doesn't even run as deep as you describe it. Sometimes I use active debugging, sometimes I use passive debugging, depending on the situation. Sometimes I just want to see the output, so passive is fine, sometimes I want to control the flow and be able to inspect things more deeply. I don't think there are people who only use one or the other.
- mybrid 6y agoThe only thing I will say is that this would not meet my personal code review standards for logging. Rule number one is never put functional calls in a logging statement, only log static data. As optimistic as one might be that the 'ic' has no side effects, the most conservative approach is to never put anything that interacts with run-time behavior in a log statement. This is especially good practice when working in many code bases in many languages. If one gets comfortable with something like say 'ic' that has no side effects when wrapping function calls then one may assume this out of habit when interacting with other such utilities, other languages. The conservative approach is best in my experience and that is to never insert run-time code in log statements and only log static data.
- Igelau 6y agoIt says on the tin that it's for print debugging. That's not the same as logging.
- BrissyCoder 6y agoImagine using a language in this day and age where you have to litter your code with debugging statements.
- deleted 6y ago[deleted]
- comeonseriously 6y agoI'd be lying if I said I never use print to debug, but honestly I mostly using logging.
- whalesalad 6y agoFriendly reminder the stlib includes the pprint module. pprint.pprint() will give nicely formatted output of data structures and lists. (Not suggesting it as a replacement for this tool - but if you’re a pyhacker and don’t know about this it’s handy)
- cool-RR 6y agoLOL, first time I write a slogan catchy enough that other people copy it :) https://news.ycombinator.com/item?id=19717786 https://news.ycombinator.com/item?id=19717786 PySnooper: Never use print for debugging again
- Igelau 6y agoIt seems like it was a coincidence. See comment thread: https://github.com/gruns/icecream/commit/ee849b840eb34242aa27b03e7ff5e1b7b3bd0312#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5 https://github.com/gruns/icecream/commit/ee849b840eb34242aa2...
- charkubi 6y agoThe problem with printing variables is when you want to find them there's nothing to search for.
- whalesalad 6y agoif you name them well, sure there is.
- offtop5 6y agoIt should take a competent programmer about 30 minutes to create a nice log class with more flexibility for their particular application. On one hand thank you for sharing, on the other hand if I add this to my project at work my boss is going to scold me
- Merad 6y agoI don't do much Python, but logging is a problem that's been thoroughly solved in just about every other language I've used. Why on earth would you reach for a half baked homemade solution?
- offtop5 6y agoI mean, the solution is print. It's just depending on your application you're going to change exactly what you log, and that's where you go and put your own logic
- rzwitserloot 6y agoThis library's 'ad copy' focuses on its ability to print the expression passed to the `log` function verbatim, but for those thinking about importing this library or something like it, I find that the most useful long-term benefit of a construction like this is this: All short-term logging / debugging calls are now properly isolated. Ordinarily, if you spot a `print` statement in code it's usually a left-over relic of some previous debug session. Or it's the command line printer, who knows? With a call to ic, you know it's short-term logging and nothing else. You can search for them, you can spot them immediately in commit changelogs, you can write hooks if you want to ban them from ever appearing in certain branches, you can breakpoint them in your IDE, etcetera. For many apps, _all_ print statements work like that, but I've worked on more than a few that have a 'print to standard out' component to them.
- jshprentz 6y agoI use PySnooper[1] when code behavior deviates inscrutably from my mental model. Like Icecream, PySnooper exhorts, "Never use print for debugging again." A simple example: import pysnooper @pysnooper.snoop() def add_up(numbers): total = 0 for number in numbers: total += number return total add_up([123, 456]) When run, PySnooper prints the activity of the decorated function or method: $ python example.py Source path:... /home/joel/example.py Starting var:.. numbers = [123, 456] 08:46:58.742543 call 4 def add_up(numbers): 08:46:58.742692 line 5 total = 0 New var:....... total = 0 08:46:58.742722 line 6 for number in numbers: New var:....... number = 123 08:46:58.742755 line 7 total += number Modified var:.. total = 123 08:46:58.742787 line 6 for number in numbers: Modified var:.. number = 456 08:46:58.742818 line 7 total += number Modified var:.. total = 579 08:46:58.742847 line 6 for number in numbers: 08:46:58.742876 line 8 return total 08:46:58.742898 return 8 return total Return value:.. 579 Elapsed time: 00:00:00.000405 [1] https://github.com/cool-RR/PySnooper https://github.com/cool-RR/PySnooper
- alexmojaki 6y agoThere's also https://github.com/alexmojaki/snoop https://github.com/alexmojaki/snoop For comparison: 19:32:30.66 >>> Call to add_up in File "/home/joel/example.py", line 5 19:32:30.66 ...... numbers = [123, 456] 19:32:30.66 ...... len(numbers) = 2 19:32:30.66 5 | def add_up(numbers): 19:32:30.66 6 | total = 0 19:32:30.66 7 | for number in numbers: 19:32:30.66 .......... number = 123 19:32:30.66 8 | total += number 19:32:30.66 .............. total = 123 19:32:30.66 7 | for number in numbers: 19:32:30.66 .......... number = 456 19:32:30.66 8 | total += number 19:32:30.66 .............. total = 579 19:32:30.66 7 | for number in numbers: 19:32:30.66 9 | return total 19:32:30.66 <<< Return value from add_up: 579
- jshprentz 6y agoFrom the README, Snoop is "primarily meant to be a more featureful and refined version of PySnooper. It also includes its own version of icecream and some other nifty stuff." Thanks. I'll give it a try.
- jujodi 6y agoI just hope I don't forget about this the next time Advent of Code comes around
- anonymousDan 6y agoIs this likely to work inside something like pyspark I wonder?
- sly010 6y agoThis has the added benefit that you can turn it off in CI/CD and prevent people committing debug statements.
- nhumrich 6y agoHas nobody heard about the logging module in python? It can essentially do all of this. it's also: 1. built in. 2. configurable by others so you can add it to a library. 3. allows different log levels per line (debug, info, etc).
- knl2021 6y agoI've built https://github.com/kunalb/panopticon https://github.com/kunalb/panopticon to easily trace function execution to handle a similar use case, except that it generates output for chrome://tracing instead of printing out lines. cPython's settrace/setprofile functionality enables so many cool tools.
- permo-w 6y agoWhy does it put “ic | ” at the beginning? Branding? Maybe I’m missing something, but it seems unnecessary
- oaiey 6y agoIs something like that available in .NET. seems possible considering expression support. Maybe with bad performance.
- dfilppi 6y agoVscode has logpoints now
- randomsearch 6y agoI used to teach people to use the amazing debuggers we have now so that they'd never have to use print statements to debug their code. Since I became a front-end developer, all I've done is use print statements to debug JS. Feels like I've gone backwards.
- cdrini 6y agoWhy don't you use the devtools debugger? I generally find people in webdev tend to use debuggers more than other fields because it's so readily available in devtools, or with `debugger` in JavaScript.
- randomsearch 6y agoIt's nowhere near e.g. Pycharm as a debugging tool, is why. It's awful.
- corytheboyd 6y agoI see print debugging and breakpoint debugging as two different tools, both very useful. Print statements are useful when you don’t know where to put a breakpoint, of course, but also when it’s important to see the real-time execution along with the debug logs. Breakpoints are of course insanely helpful when you know where to put them, but also can be peppered about suspect areas and used with steps to cover wider ranges. Just to give credit to both “sides” in the comments here, you’re all kind of right and it’s okay if people have different workflows than you.
- ehsankia 6y agoThis isn't even breakpoint debugging though, this library simply makes your print statements "easier" to write, at the cost of having to install and import a library.
- jeffypoo 6y agoIn classic HN style, half of the comments have devolved into variations of dEbUgGeR bEtTeR and PrInT bEtTeR... Newflash! You can do both, and sometimes one is better than the other.
- cullinap 6y agowhat's wrong with using print()?
- czinck 6y agoI started writing a very-alpha related tool, https://github.com/czinck/pyset_x https://github.com/czinck/pyset_x. As the name implies, it's like `set -x` in bash, in that it prints every line as it executes. It's more useful for situations where you have some complicated control flow and it's not working exactly how you expect.
- cool-RR 6y agoFunny, a few months back I added this sentence to PySnooper's readme: "PySnooper is a poor man's debugger. If you've used Bash, it's like set -x for Python, except it's fancier." https://github.com/cool-RR/PySnooper https://github.com/cool-RR/PySnooper
- czinck 6y agoI saw someone mention PySnooper elsewhere in this thread, I think if I had known it existed before I probably wouldn't have bothered with `pyset_x`.
- savrajsingh 6y agoNote: VS code made it a lot easier to use the debugger, it’s basically set up and ready to go, but this is a great project too!
- aitchnyu 6y agoClojure allows this very brief copypasta `(defmacro dbg [x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))` https://blog.jayway.com/2011/03/13/dbg-a-cool-little-clojure-macro/ https://blog.jayway.com/2011/03/13/dbg-a-cool-little-clojure... Wish Python has this by default though.
- edumucelli 6y agoPycharm is a neat IDE. I know some people do not like IDEs but all the debug tools Pycharm comes with are killer and helps greatly when debugging on a local environment.
- TheRealNGenius 6y agohttps://www.wndr.xyz/posts/D5Tuu6YUqrWq8st73mn2Fw==/this-is-my-ice-cream-cone-you-can-have-it https://www.wndr.xyz/posts/D5Tuu6YUqrWq8st73mn2Fw==/this-is-...
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]
- lmagno 6y agoInteresting, similar to Julia's `@show` macro julia> @show sqrt(121) > sqrt(121) = 11.0 > 11.0 The last line being the returned value.
- roryokane 6y agoI was wondering if there was any equivalent library for Ruby. Turns out there is: https://github.com/AndyObtiva/puts_debuggerer https://github.com/AndyObtiva/puts_debuggerer. With that library, pd bug_or_band Prints this: [PD] /Users/User/trivia_app.rb:4 > pd bug_or_band => "beattle"