Python Forum
Close script from another script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Close script from another script
#11
As a cross-platform way to kill a process, you can use the psutil module instead of calling the OS directly. Psutils gives you robust ways to find the process and kill it.

Also note that if a script starts another script through the multiprocessing module, it has a pointer to the child process through which it can kill the process.
Reply
#12
In answer to reload, yes you can do that. Don't you have access to the internet?

But it is still a REALLY HORRIBLE IDEA. You should not be writing code to represent data. You should have a file somewhere that contains the number 10. You should have some code that will read the file and return the number. You should have some different code that writes a different number to this file. If you take money out of your wallet you read the number from the file, subtract the withdrawal and write the new value to the wallet. The code to do the transaction does not import the data file, it uses the file as a kind of persistent variable.
Reply
#13
I am a layman I know, but that is the only solution I have found to solve my "problem", I admit that I am not an expert like many of you who have certainly put effort into it for years. however I solved it with this method:


pt = (Wallet.pt - total_spend)
pt = str (pt)
print ("You have left:", pt, "Euro")

content = (('pt =') + pt)
content = str (content)
file_uno = open ("Wallet.py", "w")
file_uno.write (content)
file_uno.close ()

importlib.reload (Wallet)


it won't look good and it will be a horrible idea but it works smoothly.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems passing arguments containing spaces to bash script and then on to python kaustin 6 338 Apr-03-2024, 08:26 PM
Last Post: deanhystad
  Using a script to open multiple shells? SuchUmami 9 430 Apr-01-2024, 10:04 AM
Last Post: Gribouillis
  How to include one script into another? MorningWave 8 428 Mar-21-2024, 10:34 PM
Last Post: MorningWave
  ChromeDriver breaking Python script genericusername12414 1 297 Mar-14-2024, 09:39 AM
Last Post: snippsat
  using PowerShell from Python script for mounting shares tester_V 8 506 Mar-12-2024, 06:26 PM
Last Post: tester_V
  No Internet connection when running a Python script basil_555 8 575 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 463 Mar-10-2024, 07:24 PM
Last Post: Winfried
  Combine console script + GUI (tkinter) dejot 2 416 Feb-27-2024, 04:38 PM
Last Post: deanhystad
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 337 Feb-17-2024, 12:29 PM
Last Post: deanhystad
  OBS Script Troubleshooting Jotatochips 0 293 Feb-10-2024, 06:18 PM
Last Post: Jotatochips

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020