Oct-20-2017, 04:40 PM
Hello. I am pretty new to Python and I've found something that is probably pretty simple but eludes me. The problem concerns enclosing existing code in a new loop structure.
I come from a Java background. One of the things I do all the time in Java is build a small section of code for testing and debugging purposes. When I have it clean I do a cut/paste into a loop (if-then,while,for,etc) where it will be called from. The nice thing about my Java IDE is that when I do a cut/paste it automatically corrects the indentation.
I've been developing my Python in Spyder, which does have Source-->Fix Indentation option, but when I cut/paste some sections of code it doesn't "fix" them correctly. My suspicion is that in Java this indentation fix is easier because of the enclosing brackets that clearly delineate the boundaries of the enclosing structure, whereas in Python it seems as though the indentation is the only delineation.
So my question is, is there a way to mark with brackets or some such the beginning and end of a section so that it would be possible to cut/paste code into it and have the editor recognize the edges?
Thanks!
I come from a Java background. One of the things I do all the time in Java is build a small section of code for testing and debugging purposes. When I have it clean I do a cut/paste into a loop (if-then,while,for,etc) where it will be called from. The nice thing about my Java IDE is that when I do a cut/paste it automatically corrects the indentation.
I've been developing my Python in Spyder, which does have Source-->Fix Indentation option, but when I cut/paste some sections of code it doesn't "fix" them correctly. My suspicion is that in Java this indentation fix is easier because of the enclosing brackets that clearly delineate the boundaries of the enclosing structure, whereas in Python it seems as though the indentation is the only delineation.
So my question is, is there a way to mark with brackets or some such the beginning and end of a section so that it would be possible to cut/paste code into it and have the editor recognize the edges?
Thanks!