Home > OS >  What does the phrase "created at runtime mean?"
What does the phrase "created at runtime mean?"

Time:07-15

My supervisor asked me the other day if a log file in a Python script is created at runtime or not. Is that another way of asking: is a new log file created every time the script is run? Because to me everything happens "at runtime" and it can be no other way. How else could it be?

CodePudding user response:

The phrase is usually used when you cannot figure out the content of some variable/data by just analyzing the code and other associated files (such as configs). The easiest example I can think of is

x = 'hi'
print(x)

versus

x = input()
print(x)

In the second example "x is created at runtime". (Or more precisely, the data which the name x points to is dynamic and can be different in each execution.)

CodePudding user response:

Yeah i think you got it right! However if you for example would only append to an already existing log file it would not be considered as "created at runtime".

CodePudding user response:

Here is the lifecycle of a program, source Wikipedia.

You can create the log file before the run time, just create a new file in your project, or let the program create one during the runtime, if the file already not exist. The extreme case is to save all the log data in memory during the execution end create the file during the end time, but I think it's a really bad idea XD...

  • Related