When do you actually make programs
12 17 May 2016 21:23 by u/LearningPython
So i've been slowly learning python the past couple of months.I have a small amount of knowledge and almost finished a online course.However my question is i've always been running things through the websites console.And when i was learning on another website i used powershell and python to run them, but when does it actually turn into a program like a .exe or so.
12 comments
10 u/InnocentBystander 17 May 2016 21:30
Python doesn't. It is a scripting language, so no need to compile. But anyone that wants to run it must have a python interpreter on their system.
A language like C uses a compiler to turn the code into an exe.
5 u/LearningPython [OP] 17 May 2016 21:37
I see.Just shows how far i am from having a good amount of knowledge if i dont even know what im learning is used for.
I am familiar with scripts from video games however im not sure of the similarity.
I guess its time to google what python is used for : /
2 u/InnocentBystander 17 May 2016 21:51
The difference between a scripting language and a programming language is that scripts do not need to be compiled, but do need an interpreter, while a program must be compiled but does not need an interpreter.
Other than that they are more or less the same thing, though scripts are almost always a higher level language.
1 u/CarthOSassy 18 May 2016 06:08
Python has libraries to do just about anything. I once had a job that consisted mainly of reimplementing python programs in C++. The scientist tended to create everything in Python and let the interns and God sort it out.
0 u/Retron 18 May 2016 13:14
You can compile Python code in to C using a program like Cython.
Results vary but it is a method of producing stand-alone programs from Python "scripts".
1 u/TiagoTiago 18 May 2016 00:44
Isn't there some stuff you can use to compile python into binary?
0 u/InnocentBystander 18 May 2016 00:48
Not really. You can package it together with an interpreter so it functions similar to a binary. But you'd have a much smaller program to upload/download if you just sent the script and let them download the python runtime interpreter themselves. That is as much an advantage as disadvantage.
Most people who do more than just browse the internet will end up installing various runtime packages for languages like this anyway.
0 u/dizzydog 17 May 2016 21:47
You can execute a .py script directly on Windows with the command "python.exe myscript.py". You will need to add the full python.exe path (Python interpreter program) to your PATH environment variable first. On Linux and Mac you have to first give execute permissions with "chmod +x myscript.py" and then you can run with "python myscript.py".
You need the Python interpreter on a machine in order to run Python programs.
Although, for interest's sake, here are some more technical answers to the question you probably aren't actually asking...
https://stackoverflow.com/questions/138521/is-it-feasible-to-compile-python-to-machine-code
0 u/ShowMeYourKitties 17 May 2016 21:47
Python isna scripting language, so you're writing code that instructs the Python binary to do.. Stuff.
You can bundle your application into an executable archive.. But you're still going to be executing a script.
Of you're interested in compiled languages.. There are plenty out there.
Good ole' C and C++ will fit the bill.
There's C#
Golang is compiled. If you're feeling adventurous.
And that's just a few of the many.
0 u/TiagoTiago 18 May 2016 10:56
I haven't tested any of these; but I found them being suggested on a few pages:
http://www.py2exe.org/
http://www.pyinstaller.org/
http://nuitka.net/
http://cx-freeze.sourceforge.net/
You gotta evaluate the particularities of each alternative, to see which suites your needs better, or even at all.
ps: There might also be a thing called "freeze" that comes with Python, that does something like this; but I don't got the time to research right now if it is still being included in more recent versions of Python
0 u/Sermo_Mercurialis 18 May 2016 19:20
Just put it in the fridge overnight, then it'll automatically become an .exe.