Automatically end Python process after running in REPL [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I often debug Python using a Sublime Python repl extension, and the processes often stack up without closing. Is there something I can append to the end of my code to automatically end the repl process? I can right click it to 'kill repl,' but am looking for an automatic way.
I have tried using exit() and sys.exit() but they do not terminate the processes. Frankly I'm not remotely aware of how REPL or terminals in general work under the hood.

I'm not too familiar with sublime text, but from brief searches online on the most prominent REPL (https://packagecontrol.io/packages/SublimeREPL) it looks like the REPL is part of the sublime process which might be why exit() and sys.exit() aren't working. It looks like you can just close the window tab and that ends the process but i'm not 100% sure.
Although it might not be a solution to your specific issue (I can't comment on SO yet), if you are looking for an interactive local REPL for debugging and testing a good option might be ptpython. It has autocomplete and you can use exit() since it's actually a separate python process, but it does require a separate terminal (unless there's a sublime integration).

Related

Starting fresh without pycharm [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I would like to get more experience with the different elements that running and writing python involves. I used Pycharm to start writing code.
Pycharm is great at simplifying the whole process, which includes obscuring even the simplest parts.
I'd like to move my projects to a more hands-on editor.
I really like syntax highlighting and completion so an editor with those attributes is preferred.
You can try to use Atom or VSCode. More information about atom can be found here: https://atom.io/
About VSCode try this link:
https://code.visualstudio.com/
When it comes to moving projects to another text editor, PyCharm creates certain files in order to store the scripts, and you can find those files like this:
as you can see, this is the left side window in pycharm, and next to the title there is a path. That path is where the file is located.
You can drag and drop the scripts to the icon of the new text editor in order to open them from there.

Could you check it's possible (Selenium python automation + PHP) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Our system is developed with PHP and one of our coworkers developed Amazon automation program with Python.
I am wondering if it's possible to integrate together ?
if it is please recommend what ways i can do this
https://github.com/jasonminsookim/order_automation/blob/master/src/amzn.py
Here's code Amazon automation program
Thank you
There are lots of ways to do this, but I would weigh what you have available to you and go from there. The tempfile solution is the most general, and is a common interface pattern for any two or more languages, but you can get more exotic if performance is a major concern with pipes.
Temp-file
I guess the most rudimentary way to do this would be to have the python file output some data to a file that can be read in by php or vice versa.
Something like creating a directory called /orders where php put's in order.json files and python takes those in, reads them and gets the result, then puts it back as a order-result.json. Essentially a temp-file system to communicate between the two.
Pipes
Alternatively depending on your setup you could pipe results into php from python with something like the subprocessing module and a php CLI that interfaces with your DB.

SImilarities between exec and os.system() [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to multi-threaded programming in python.
Can someone tell me whether os.system("ls") in python and exec("ls") call in "C" are doing the same ?
Please tell me about the similarities and dissimilarities as well.
In C, exec(whatever) replaces the current process's code with the code from whatever. Thus, it never returns. You can do the same in Python with os.execv and friends -- see https://docs.python.org/2/library/os.html#process-management .
os.system(whatever), on the other hands, forks the current process, execs whatever in the subprocess, waits for it to end, then returns. So, it's the same as system(whatever) is in C: a simple layer on top of fork, exec, and wait system calls (in Unix-like systems; simulated by other means in non-Unix-based systems, of which I believe the only one around in substantial numbers these days is Microsoft Windows).

Python chat reading and writing simultaneously [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to build a client side chat which can send and read messages simultaneously.
One problem is that when I write a message, if someone else sends something its disrupt the message I am writing.
Another problem is the raw_input which blocks the user from reading new messages.
I tried to fix this problem by using msvcrt which causes another problem (I cant see the message I am writing and edit it).
How can I fix those 3 problem?
===>edit: Without using threads.
I think you may need asynchronous sockets...that will give you ability to handle sending and receiving in a single thread.
Look here for asynchronous sockets in python. This will let you code it "bare bones" (i.e. keep most of your code and just use the sockets).
Another option is to use Twisted. This has some complications, it is a complete framework, but it gives you a lot of lift.
You can also try multi-threading. This is not trivial to do, however.

Using Task Scheduler vs Multithreading [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I needed to perform a heavy operation while using a Tkinter GUI. So the GUI would stop responding as soon as the operation began. So, I had two choices(or that's what i think,as I'm new to python & programming as well): MultiThreading or Schtasks .
So, I chose the easier of the two,i.e Schtasks, as I'm working on a deadline(& I dont know much about Multithreading).
What I'm doing is accessing a python file from a different project.
I run batch files which is in this different project(which contains the desired python file that i need to run) to be run by Schtasks
Now the constraint is batch file can access only this python file & not a particular method present in that file(isn't it?) & I need to access only a particular method .
So, my question is:
Is the approach I'm using correct? If not what do you suggest would be better ? Or should I just switch to MultiThreading
Your question opens a huge topic - what you are trying to do is generally not simple and can have large problems which you cannot even foresee if you don't know the topic of multitasking very well. One issue, for example, is synchronizing the access to the file you mention from within different threads or processes or tasks.
However, if you want to start somewhere and just want to write something which separates your GUI code from your computation code, I recommend you start here: http://docs.python.org/2/library/multiprocessing.html .

Categories

Resources