Jumping Around A File Video Tutorial

Hey, i’ve made a video about how to go backwards and forwards in a python file. I think this is
an interesting concept and it makes it more interesting to make small prototypes for people like me who don’t have too much experience making projects in python.

Using a text layout program is quite strange. There are special programs for the code, such as Notepad++. And instead of the console, you can use a BAT or CMD file to run the code.

I could use a editor designed for programming, but i don’t want to. I think it’s easier to understand something if there is visual correspondence, which is what i’m trying to do to make taking notes easier for myself. I don’t plan on doing it for everything but the concept in the video is already strange and i think using a word processor might be more interesting for people who are interested in these things. I’m just glad python has the ability to support these kind of approaches since i can just run a text file in the interpreter.

1 Like

I didn’t really understand what the video was about. However, it is not clear why to use a word processor as in the example. This is easy to do with a normal function. To be honest, I still wonder what the point of the video is.

This is an interesting and unusual approach!

And, well, if it works for you, in the projects that you make, then I won’t gainsay it.

It’s not a way that I’d recommend in general, but if someone does find it useful, then fair enough.

Hmm… Perhaps I’m missing something, but what would happen if, in the block of code marked “2”, you had something like a variable given the value “3”, or some value multiplied by “3.5”, and then searched for the marker that you designated “3”?

Would the search procedure find the code and seek to that, instead of the marker?

(And if so, could you perhaps improve that by prepending your search-string with the hash-symbol, so that it’s searching specifically for a number preceded by a hash?)

I can agree there isn’t too much of a point but things like this could be what give me ideas to program something outside of a personal project. I just think being able to move backwards and forwards in a program is neat.

I use the assumption that everything that a user searches for is a comment, so moving to that point in the file and executing the comment won’t do anything. It’s just a place to start so python executes everything after it.

If I understand you correctly, you tried to do something like GOTO. This is already implemented on the side.

1 Like

I mean, rather, that if I’m reading your code correctly you’re just searching for the number, alone. That means that if such a number occurs outside of a comment, then it may be picked up in place of the intended marker, regardless of the user’s intent.

Execution from such a point may then be other than as desired.

For example, if you have the following:

testVal = (someOtherVal * 3.5)

print ("Cats are cute!")

And you try to jump to “3”, will your code not jump to the first “3”–the one at the start of “3.5”, and then attempt to run from code starting with “3.5)”–which by itself isn’t valid syntax?

Yeah, it would cause an error if i only search for 3 but i’m going to try to not do that. I also tried putting something similar inside a string like:


That looks like it causes problems too but i’m ok with the strengths i have with it right now.

That’s fair–as long as you’re aware of such potential issues,and they don’t cause you problems. And indeed, it seems that you have them in mind! :slight_smile: