equivalent of go to

when you write a function

and you want to skip some of the lines temporarily is there something like a goto command

this should be faster then put a # at beginning of lines
mostly when you have lot’s of lines in a function

and how to write it ?

Thanks

indenting the lines you want to skip and putting if False: in front of it might be a simple way to do it

Do you have access to a code editor for your platform that can at least color-code comments? It is not for everybody but I use emacs which has a python-mode and the functionality to comment and uncomment blocks of code. (Warning: emacs is beautifully complicated and has a learning curve very close to Blender’s.)

The ‘vim’ editor is available for most platforms and has some handy language-sensitive functionality.

As you can see I am not familiar with MSWin editors. I agree it would be nice for script development to be able to skip over bits of code with something equivalent to the c preprocessor’s ‘#if 0’ ‘#endif’ declarations.

I use a development system called EasyEclipse for Python. It allows one to highlight a block of lines, then automatically place a # at the start of each line with one keystroke. Or remove the #s at the start.

This is a reasonable solution if you have an editor that can do block indenting and un-indenting.

certainly blender built-in editor can do it too.

Another way that won’t require changing the indentation is to use the multi-line quote. For example:

Here is a sample function


def myFunction:

    y = 1
    x = 1
    x+=1
    
    print x
    print y
    
    z = [x, y]
    print z

To stop the printing of x and y – in this case – without having to wrap with an if block or add # for each line you would use three quotes before and after the lines you don’t want to run.


def myFunction:

    y = 1
    x = 1
    x+=1
    
    """
    print x
    print y
    """
    
    z = [x, y]
    print z

ok i’m using notepad2 which has some color coded things inside
it’s not perfect but it’s working fine

i mean i’m not really a programmer so i continue using this unless there is a better one inside blender
the problem with the console or inside blender script window is that it’s impossible
to change the size of things zoom in or out and i did not see any color scheme but may be it’s part of 2.48a got check more i think

i guess the “”" is probably the fastest and simplest thing
hope what day they come up with some way to skip line like a goto command
it would be nice to have this feature

Thanks
Salutations

“goto” is simple but risk: could harm code structure. I don’t think it could be a part of python.

Actually you might be interested in some debugging utilites (makes it possible to execute certain lines only if you’re in debug-mode). But this also depends on what your code-editor has to offer.

And GOTO is probably not a good way to do it anyway. GOTO is a command that exists in many languages but I have never encountered a case in which it would be absolutely necessary to use it (granted, I’m not very experienced) and everywhere you look, its use is discouraged. The reason being that it is very easy to make unintelligible code that no-one understands (so called spaghetti code…).

I think it is a good recommendation not to use it :wink: (and yes, python does not know it, as far as I know).

I use programmers notepad.

http://www.pnotepad.org/download/

I’m a fan of notepad++
http://notepad-plus.sourceforge.net/uk/site.htm

There actually is a goto module for python… it was an april fool’s joke but apparently it works. :smiley:
What I think it would be kinda useful for is breaking out of for-loops but that’s about it. No need to discuss what goto does to your code.

what the differences between theses program

notepade2 and notepad++ ?

i did try to use tje qutotations inside a function and
cannot get rid of the error indentation error !
so a goto might still be very usefull even if it is used only on occasions
for debugging purposes not as a normal feature

Thanks