Python Forum
Import output from python script to another
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import output from python script to another
#1
Hello
I want to find a solution which make me do the whole idea below:
I want to import an output of my python script in another python script file(i have 2 python files )
The first one :File 1. py contains an output string that auto change after a while..

out1 = 'function' ( the values change after some time)
i want to import the out1 in the other file (File2. py)..and get the values after any change from the file1. Py
how may i solve this i tried with loops but nothing. Thanks
Reply
#2
In my programs, I wouldn't want to use import this way.  It's too easy to bring in unexpected things.  Simpler I would think would be to put the information in a container (list or dict) and then put that into a file (perhaps via JSON formatting).  Then you can read it in whenever you want into a variable that you control.

But if you do want to use import, it will normally only attempt read it once per program invocation.  Take a look at importlib.reload to re-import a previously imported module.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,008 Jun-29-2023, 11:57 AM
Last Post: gologica
Question How can I import a variable from another script without executing it ThomasFab 12 7,558 May-06-2022, 03:21 PM
Last Post: bowlofred
  Real-Time output of server script on a client script. throwaway34 2 2,010 Oct-03-2021, 09:37 AM
Last Post: ibreeden
  Using import in python script offline - HELP!! blackhatter1001001 1 2,220 Jul-25-2021, 05:57 AM
Last Post: ndc85430
  Python script to summarize excel tables, then output a composite table? i'm a total n surfer349 1 2,290 Feb-05-2021, 04:37 PM
Last Post: nilamo
  Census geocoding services API. How do I import output into dataframe? SAS2PYTHON 3 2,521 Nov-10-2020, 11:10 PM
Last Post: SAS2PYTHON
  How to kill a bash script running as root from a python script? jc_lafleur 4 5,789 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,248 May-28-2020, 05:27 PM
Last Post: micseydel
  Import Text, output curve geometry Alyner 0 1,932 Feb-03-2020, 03:05 AM
Last Post: Alyner
  Manipulating the filename of an output script mckinneycm 4 11,827 Jan-15-2020, 07:29 PM
Last Post: mckinneycm

Forum Jump:

User Panel Messages

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