visual studio code equivalent of python -i - python

I am looking for the equivalent of python -i in VScode.
That is, a way to open a terminal (or run in the included terminal) the program that is open, and use the program in the read-print-eval loop, being able to call functions and inspect variables freely.
I searched for this plugin without success.
I need it to be around as simple as pressing f5 and typing something. I want to use it to teach, and my students already have many difficulties with algorithms and coding. Also, easy instalation would be ideal. I am sorry for being that 'demanding', but classes are huge and the chance of getting everyone to do a procedure go down fast with the size of the procedure.
I would not mind creating such a utility myself, if someone will point me the way, and then uploading it to whatever 'store' VScode downloads its plugins from.

Related

Is there a way to launch a python script as a apk without seeing the code first without encapsulating the script inside the apk?

I'm a student and got the opportunity to write a python program set for a friend's company's production area. It is basically several math functions with error checking and a menu. Finished the program and it works well, but I have one concern.
The program needs to be scalable, which I have built in templates to do so.
The problem I have right now is its only launchable via an IDE.
I don't want the workers to see the code, and accidently break the code when launching.
But I also don't want to compile the code into an apk, as it needs to be easily changeable.
So my question is thus: is there any way to make an apk that just launches the core script, brings up a python console and loads it's dependencies from a file structure that can easily be accessed by something like qPython without first showing the code to the user?
The reason this is necessary, is the people in charge who will write new programs only know qPython and program stuff as if it were fortran, adding a layer of something like Android Studio might make it where they never remember how to update their program, thus never do so.
Everywhere I look there is only options pull the whole script into an apk.
Thanks in advance for the input.
So tl:dr looking for a method to have push button run python console script on a android, if it exists.

running a python script when i turn my pc on

I created a python script to control the RGB of my keyboard and my mouse and i want it to start when i turn my computer on. I have 2 solutions but i don't know which is the best.
the first solution is to build my script and run the executable on startup
the second solution is to run directly the python script with python.
the first solution is a little bit annoying because is i want to change the code, i need to rebuild my script. and also when i tried to run the exe (created with pyinstaller), it didn't work (because of the dlls i think)
the second solution is better if i want to change the code later, but i don't know how it would react if i run another python script (i don't even know if it's possible to run 2 python instances at the same time.)
so if you have any idea on which solution to choose, how to build a script using dlls with pyinstaller or if i can run multiple python instances (maybe i can run multiple venvs), feel free th help me.
PS: I tried to be clear but as i didn't speak english very well i don't know if you understood my issue.
Using windows : https://www.geeksforgeeks.org/autorun-a-python-script-on-windows-startup/
Using Linux : follow this https://stackoverflow.com/questions/24518522/run-python-script-at-startup-in-ubuntu#:~:text=Put%20the%20command%20python%20startuptest,and%20put%20the%20command%20there

Running Python Scripts Outside of IDLE

1- i want someone to help with this part
https://automatetheboringstuff.com/appendixb/
about Running Python Scripts Outside of IDLE and sending command line args .
2- i converted my code to .exe by pyinstaller ; what's the difference between this and running it
as a script .
3-how scripts are done . i see experienced people says :"i made a script to do something for me " how is that done >?
*i'm a beginner so try to make answers simple as possible.
If you're wondering about command line arguments, look into the "argparse" library https://docs.python.org/3/library/argparse.html.
The difference in the .exe and the normal script is that that the .exe versions (conventionally) are able to be redistributed to other sytems that don't have python installed whilst still being able to run the script. If you're only making the script for yourself the only real benefit is that you dont have to enter your IDE (code editor) every time you want to run the code, however if it's still in development then you'd have to compile the code every time you made a modification if you're wanting to run the code as an executable, which is very impractical.
Your third part is very, very vague. Python can be very versatile and i recommend you continue looking at the automatetheboringstuff.com website if you're interested in making scripts that can complete repetitive activities (although i must strongly advise you against using scripts maliciously).

iteratively and interactively writing and testing python code

I'd like to iteratively write and test my python code in the Python console. I can't find a way to easily load what i've got written in the editor (somefile.py) into the Python console in Pycharm. Is there a trick to doing so?
Pycharm will let me run the entire script but that's not useful because i want to build up my state in the shell by experimenting with the functions and data i've got in the environment (kind of like how a lisp programmer would use a REPL).
Pycharm have this alt-shift-E option.
This way you can write in the editor, select the lines you want to run and run them by alt-shift-E.
I use it all the time, although I find a lot of people not fameliar with this option.

Py2exe executable shows black command line window

There was a simple task - well, in Python it took around one hundred lines of code (the task was only to ask users for input files, process them and write results on disk). But the requirement was that it must be executable on PCs without Python interpreter. I used py2exe to make an executable file (it has increased the size from 3Kb to ~12 Mb but doesn't really matter).
The problem is - when one tries to run this *.exe, it shows black command line window for half a minute and only after that - file-selecting dialogue. Is there a possibility to get rid of that half-minute delay? Of maybe there are other .py to .exe converters which would suit better in this situation?
In py2exe
console = ['yourscript.py']
will generate a command window, use the following instead
windows = ['yourscript.py']
http://www.py2exe.org/index.cgi/ListOfOptions
This is perfectly normal when making exe files with Python code. When you make an executable file, Python itself is bundled into the .exe. This is so the user does not have to install Python on their machine to make it work. Python is an interpreted language and requires the interpreter to be bundled.
You could always try using alternatives to see if the compression rate is smaller, but chances are, its not a big deal.
If it is the code that is taking a long time, you may consider posting your code on Stack Exchanges' Code Review to see if there is anything that could be improved.
Further, if you are using Python 2.7, you should consider checking out PyInstaller. It is surprisingly easy, however, it has a couple of problems - especially with the PySide Framework - works great for plain PyQt though.
pyinstaller myscript.py --name="MyApp" --onefile
However, for a full list of optional parameters you should really check out the documentation.

Categories