Python Forum
executing a file saved in memory
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
executing a file saved in memory
#1
i would like to make a script that reads in a python source file, then later (the file is no longer on this host's filesystem(s)) run that file.

it would be a big plus if i can capture the global and local namespaces that running it produces.

i have already done the above with the exec() function.  i need to further test it to see what scope of sources it can run.

it would be another plus if can, or if there is some way to, capture the output of running this file.  i'm thinking that pipes taking on stdout and stderr output could be a way to do this.

it would be another big plus if it can, or if there is some way to, do all this for .pyc and .pyo files that were read in without writing to a file (on an embedded device, for example, that only has read/only file mounts).  i have no idea if exec() knows how to do this but it would be great if it can.

the form that the file needs to be stored in to be run for all this only needs to be documented.  if it can only be done in python 3.5 and later, that is ok.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Function not executing each file in folder mathew_31 9 2,170 Aug-22-2022, 08:40 PM
Last Post: deanhystad
  Using .pb saved model for object detection hobbyist 2 1,139 Aug-03-2022, 05:55 AM
Last Post: hobbyist
  bytes object saved as .mp4 jttolleson 10 5,752 Feb-25-2022, 02:42 PM
Last Post: jttolleson
  executing a bash file - revisited ebolisa 7 2,826 Feb-10-2021, 08:05 PM
Last Post: Gribouillis
  Why can't numpy array be restored to a saved value? pjfarley3 1 1,683 Nov-25-2020, 07:40 AM
Last Post: pjfarley3
  Only getting last record saved...Why Milfredo 10 4,276 Sep-10-2020, 03:00 AM
Last Post: Milfredo
  Running scripts and location of saved interpreted user-defined classes and functions leodavinci1990 3 2,468 Aug-25-2020, 03:43 AM
Last Post: micseydel
  Save a file uploaded from client-side without having to read into memory andym118 3 4,998 Nov-21-2019, 07:34 AM
Last Post: DeaD_EyE
  Saved Programs jpburrall 3 2,555 Sep-02-2019, 11:43 AM
Last Post: ThomasL
  How do I edit saved Python 3 script? Mocap 1 2,006 Jul-17-2019, 08:41 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

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