r/beneater • • Jul 02 '21

Help with Python, please im SO lost

Post image
0 Upvotes

29 comments sorted by

4

u/TheBearSlicer1 Jul 02 '21

The text editor Ben Eater is using here is called Vim. Vim is very advanced though so I'd recommend Vscode. Google "how to set up vscode for python" and you should be all set. I recommend learning some programming before you follow Ben's videos.

1

u/janovich89 Jul 02 '21

Okay , I'll check that out... and what is this?

2

u/janovich89 Jul 02 '21

after he typed things out in a text editor, how does he " run it"

1

u/Galactic_Empire Jul 02 '21

After typing his python code into makerom.py he runs it by typing “python makerom.py” into the terminal which is the first command you see in that photo you linked.

1

u/janovich89 Jul 02 '21

Does he use Vim text editor to type python code and then save it as a file named makerom.py, and then open python and type "python makerom.py" as a command to "run" it?

1

u/gfoot360 Jul 02 '21

Almost - he didn't type "python makerom.py" into python itself, he typed it into a command prompt.

3

u/janovich89 Jul 02 '21

I'm in the process of taking a tutorial on Vim, because while it may be more complicated, I feel as though using a different program will make it more difficult to follow along with Ben. Do you think using vscode will be more simple though really?

3

u/gfoot360 Jul 02 '21

Yes I'd expect so. I use and love Vim but it is arcane and not necessary here. Any text editor that you can use to type the code in will be fine, even notepad.

You do need to learn to use the CMD command line though, which is the windows equivalent of what Ben uses on his Mac. You need to be able to at least change directory and run python from there.

1

u/janovich89 Jul 02 '21

Do you have any link to a good place I can learn about cmd, and directories and all that? I feel I pick stuff up pretty quick but having no experience and not knowing the terminology trying to find information gets difficult LOL

1

u/Galactic_Empire Jul 02 '21

You’re right that he definitely uses vim to create the file, edit it, and save it. But after that, when he goes back to the terminal, he runs the python code directly by typing “python makerom.py”

There are two pieces to that command.

  1. The program to be used (python)

  2. The file name the program should run

If you were to type just “python” into the terminal, it’ll run a live interpreter which isn’t what he’s doing. The interpreter will do exactly that, interpret each line you feed it as python code and run it then and there which isn’t what you wanna do in this case.

1

u/janovich89 Jul 02 '21

What do you mean by terminal?

1

u/Galactic_Empire Jul 02 '21

That window you have open in your photo is called a terminal. Also called the Command-Line.

It’s a very powerful tool that programmers use because it doesn’t require you to use your mouse.

1

u/janovich89 Jul 02 '21

So by terminal, you mean the python terminal? Because I assume the term terminal can also be used for things like shell or command prompt correct

1

u/Galactic_Empire Jul 02 '21

Actually looking closer at your photo it looks like you have the interpreter open. On windows I think you can look for the CMD program (command line) to start doing what Ben is doing.

I’d suggest learning a bit of the basics on how to use the terminal before hand though.

1

u/janovich89 Jul 02 '21

Okay so terminal is more of a command line thing whereas python itself is an interpreter? Which I take to mean that it interprets higher-level language into machine code , so it (python interpeter) won't recognize command line instructions?

2

u/Galactic_Empire Jul 02 '21

You’re getting close. Python is just a program like anything else. Ben is just running that program in his terminal giving it parameters (ex: python makerom.py)

Makerom.py is a parameter passed to the python program telling it which file to run.

Without passing any parameters though, the python program runs a live interpreter when you can input python code.

→ More replies (0)

2

u/BigCandySurprise Jul 02 '21

It is better to you to understand the terminology, terminal is a environment where normally has a shell command language, which shell is a program that interpret commands basically, in case of windows I think it is powershell, with the shell language you type commands so your computer can do stuff, it is like a interface to run programs, like you graphical interface for example when you click on a file, when you type python in a shell environment, you are specifying to the shell to open python, if you pass as a argument the name of the file that you want to run, it will run the program that you specifyed, you can run any program in the shell environment, try typing the name of your browser for example, I highly recommend you to use linux also, things are easy there with shell and terminals.

1

u/Galactic_Empire Jul 02 '21

You’ll know when you’re in the python interpreter when you see “>>>” at the start of every line. You can exit by typing “exit()” to get back to the terminal where you can run more terminal commands

0

u/janovich89 Jul 02 '21

How does he make makerom.py?

2

u/janovich89 Jul 02 '21

3

u/tramlaw101 Jul 02 '21

Like user u/gfoot360 said. Open up notepad and start typing.

3

u/janovich89 Jul 02 '21

I know NOTHING about python, or shell. I can't figure out how to make files, or where to write code. I'm not sure at all what to do. I'm using windows 10. I can't follow Ben's videos.

1

u/BigCandySurprise Jul 02 '21

I can help you if you want, I went to the same rabbit hole once

2

u/janovich89 Jul 02 '21

Good to know, thanks much! I'll probably hit you up if I get stuck lol