Now obviously, and just like the original version, this kind of crap shouldn't be left in production code.
The trick is to enclose your two blocks of code in triple"s preceded by a regular # python comment character, and then add another three"s (but without the # character this time) between each block, like so: # ' some_working_code ' test_stuff #.Maybe pep8 does this too, but i don't use it, so i don't know).(It actually works in any language that supports the C syntax of line and block comments, but that's not the point).because i like geeky tricky tricks like this.It's confusing (most people reading it will probably just go FTW) and leaving dead code in is rarely a good idea.and is only useful in certain, not so frequent situations, but when it does make sense it's a very nice time saver (also, situations in which it comes handy tend to be quite frustrating to begin with, and if you ever coded anything, you know.Ever heard of what i like to call the.The syntax is even clearer than the C like version, and it's easier to figure out what's happening than with the fun but hard to remember mess of slashes and stars used in the above link.
It's a neat little trick, very handy when you're trying stuff out and find yourself having to repeatedly switch between a copple of code blocks.
But hey, namoro roma sexo it's still time better spent than fighting with your editor (I'm discovering SublimeText by the way.
In a non-trivial program, having to recompile the whole thing will probably negate most of the time gain.
Well, for some weird reason i thought about it again last night and since i was bored and didn't want to sleep, estou procurando rapaz amante dos animais i figured i'd waste some time and come up with a python equivalent.
Also, conclusions are still for pussies.But then i thought "Onoes!It's actually quite simple to emulate the block comment syntax by using triple"d, multiline strings (that's basically what happens when you're writing docstrings).The first three"s are ignored, since they're commented out, and so the first block is left alone, while the second one is treated as a string just sitting there.God damn python doesn't support this comment syntax, so i can't use it!".
But if you simply delete the first ' some_working_code ' test_stuff # now the first block is treated as a string while the second one is left alone (and the last line doesn't start another multiline string since it's commented out).
But I think it's a nice thing to know when working or debugging some code (you know, "I don't care if it's ugly and messy, i'll clean it up when the damn thing works!