Python Forum
Running operations without compiling code multiple times
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running operations without compiling code multiple times
#1
Hi all,
I am fairly new to Python, though I have computing experience in other languages. I have a very basic question here: I want to run operations (mathematical and plotting etc.) in the python environment but I do not want to run my code over and over again as it takes a few minutes to run. 
Now I am compiling my codes in the terminal as 'python programname.py', but once the program is complied if I want to add an extra line or make an extra plot I have to run my code again. I am sure this should not be the case, there must be someway where you can compile the code in the python environment and then do operations using the lists or variables defined in the code (without running the whole program again). It would be great, if you can help me out with this. I use mac unix. Thanks in advance.
Reply
#2
Try using -i with Python (before your script); this will run your script and then dump you in interactive mode. Note that you won't have access to any function-local variables, you'll need to make sure any state you want access to is available after the script completes.
Reply
#3
Thanks a lot !
Reply
#4
(Nov-01-2016, 04:17 PM)micseydel Wrote: Try using -i with Python (before your script); this will run your script and then dump you in interactive mode. Note that you won't have access to any function-local variables, you'll need to make sure any state you want access to is available after the script completes.

That's some dark magic, right there.  Having never actually read the arguments to python, I would have assumed -i was the default, and that it started interactive mode.  Running a script and then giving you an interactive environment at the end of it?  Wow, that's like, magic debugging material, or something.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in running a code akbarza 7 547 Feb-14-2024, 02:57 PM
Last Post: snippsat
  writing and running code in vscode without saving it akbarza 1 346 Jan-11-2024, 02:59 PM
Last Post: deanhystad
  the order of running code in a decorator function akbarza 2 480 Nov-10-2023, 08:09 AM
Last Post: akbarza
  Different code execution times Wirbelwind94 4 710 Oct-06-2023, 12:30 PM
Last Post: snippsat
Question Running an action only between certain times alexbca 9 1,659 Mar-15-2023, 04:21 PM
Last Post: deanhystad
  python multiple try except block in my code -- can we shorten code mg24 10 5,895 Nov-10-2022, 12:48 PM
Last Post: DeaD_EyE
  Code running many times nad not just one? korenron 4 1,326 Jul-24-2022, 08:12 AM
Last Post: korenron
  Error while running code on VSC maiya 4 3,551 Jul-01-2022, 02:51 PM
Last Post: maiya
  Replicate Excel operations with Python Lumberjack 3 1,773 May-10-2022, 01:44 AM
Last Post: Lumberjack
  code running for more than an hour now, yet didn't get any result, what should I do? aiden 2 1,424 Apr-06-2022, 03:41 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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