5 ms·
My biggest peeve writing Python 3 is pretty trivial... I cannot get used to typing print() Every time I go to debug a line, I get a syntax error, and have to
by syllogism 12y ago
My biggest peeve writing Python 3 is pretty trivial...
I cannot get used to typing print()
Every time I go to debug a line, I get a syntax error, and have to go back and change it. And I type a lot of debug lines!
I need to find a vim extension to handle this, but so far it just makes me frustrated whenever I try to type Python 3.
- rquirk 12y agoHave you tried using the logging module? Might be overkill for really small scripts as it requires a few lines to set up, but even the tiniest tool ends up requiring print-debugging at some point. With logging it works the same in 2/3, you can leave all the debugging statements in, and if a library also uses it then you get additional debug output from that too. Add a "debug" command line flag to pass when something goes wrong down the road (to change the default log level), and you don't have to add/remove statements for debugging. For a vim extension - I use snipMate http://www.vim.org/scripts/script.php?script_id=2540 http://www.vim.org/scripts/script.php?script_id=2540 It's a bit on the dead side but works great as-is. ifmain followed by the expander key (shift-tab in my case) expands to the if __name__ ... idiom. You could add your own "p" snippet that expanded to print() in python code.
- lmm 12y agoYeah that really is trivial. print now works like any other function, like it does in most languages. The new way really is objectively better. Short of allowing all functions to be called as "function argument" à la Haskell (which I would support, but would be a massive change) I don't see any alternative.