Why is 'goto' seen as bad form? - python-3.5

I would find it very useful in Python, and am curious as to why Python doesn't have it. Thanks!

Normally goto is explicitly used to make error handling more simple and code more readable by languages like C. Python has try and except for this, so that makes the goto statement unnecessary.

Related

How to best troubleshoot "Next without for" Compile Error

My code is pretty long and has a lot of If statements. There are also a few small for loops all nested within a larger for loop. I am getting a compiler error "Next without for". I am sure I am missing something pretty simple. I just can't find it. Is there some editor that I can use that will pair the statements and show me where the disconnect is? Is there some great method for tracking down an error like this? I certainly hate to ask anyone to pick through my code and find the error. I'd like to learn to help myself. I am in learning mode.
I was missing an End If statement. That was my issue.
Thank for the replies. I thought I had indented properly, and I think that going through line by line and checking that would have found my issue.
I ended up finding it by going through and cutting some of the blocks of ifs and loops inside of the big loop until I found the offending section.

I'm trying to use the turtle methods, etc. listed on the official python page but I keep getting errors

I'm using turtle to create a video game.
I'm making this program for a virtual class, and I don't know the exact limitations of the (online) IDLE provided. I'm not currently able to test my code in any other environment. I don't want to use pygame or anything because I don't know if I can and also I don't want to rewrite a bunch of my code.
The problems I'm having are mostly with the TurtleScreen/Screen. I can't call .Screen() or .TurtleScreen(), .bgcolor(), .turtlesize(), and probably a lot more I haven't checked yet. Here's an example:
bg = turtle.Screen()
turt = turtle.Turtle()
bg.bgcolor("black")
I just receive a
ParseError: bad input
when I run it. Any input is much appreciated!
A parse error usually comes from python being unable to parse your code rather than an issue with Turtle.
The code snippet you posted above works fine so the problem is likely with some other lines of code that precede it. Double check your syntax on lines before the error occurs and make sure there aren't any missing parenthesis, brackets, quotes, etc that would impact later lines.

Vim-Sexp - How do I move each inner form to a new line?

I have the awesome vim-sexp and vim-sexp-mappings-for-regular-people plugins installed, and I've come across a situation I'm not sure how to solve.
Suppose I have the following form:
(alimony barbara (code determinant) eclair final-countdown)
How can I transform that to:
(alimony
barbara
(code determinant)
eclair
final-countdown)
I can go ahead and insert a newline before every inner-form/element, but that is a bit tedious. There should be a way with or without the sexp plugin
This is an old question, but maybe an updated answer will help someone who comes here in the future.
You don't have to write the program mentioned by Kaz. Others have already done it. I have not tried them, but here are a few:
fipp,
cljfmt,
cljstyle,
zprint,
joker. (The last one does more than code formatting.)
As Kaz suggests, once installed, you can pipe code to a formatter using !. You can even bind this operation to a key combination. Some of the formatters offer suggestions about how to do this sort of thing.
In addition, some vim IDE plugins, such as vim-iced provide support for using an external formatter.
A productive way to get this behavior would be, rather than fighting with Vim modules and extensions, to write a Lisp program which reads S-expressions and outputs them reformatted in the desired way. To use that program out of Vim, just pipe a range of lines into it using the ! command.

MSVC++ Preprocessor - How do I output a define's value with a compiler macro?

I tried
#error MY_DEFINE
But all that did is echo "MY_DEFINE" when it threw the error.
Thanks!
You can tell the compiler to save the preprocessor output (/E or /EP) and then look at that file. That's usually how I debug problems related to macro expansion.
If you're trying to make some cool error facility for a library, you might be out of luck. I think you'll have a hard time getting the preprocessor to expand a macro into a compile-time message. Perhaps if you combined a template trick that used the macro, you could get it to appear in a cryptic compiler error message.

Search tool that uses a grammar rather than regular expression?

Are there any search tools that allow you to set up a simple token/grammar parsing system that work similar to regular expressions?
What we want to do is search our ColdFusion code for queries that do not have cfqueryparams in them.
A regular expression gets a bit tough in this situation because I can't keep track of the start tags while looking for something else before getting an end tag.
It seems like a parsing system would work more accurately.
Seeing it is XML, I would just use XSLT.

Resources