What is run time modification in python

please help me out, what is run time modification in python

Welcome to the forum.
Can you be more specific on where and in which context you came across this term?
Did you do some research and came across something you don’t understand and need help with that?

1 Like

I am doing an internship in the company so they ask me.
actually they said how we can change the function in run time
so they told me the term run time modification

I am giving you the link of stackover flow

check it out, plz help me to understand properly

I haven’t heard that term before. When I punched it into Google, this is what I got:
https://www.codesansar.com/python-programming/monkey-patching.htm
Is this what you’re thinking of?

1 Like

thanks for looking into it
actually, it’s mean that how we can change the function during run time
I am doing an internship in a company so they give me a term run time modification

I am giving the link of stackover flow

plz help me to understand properly

I’m still not sure what you mean by ‘during run time’. The code has to be written at some point. Are you talking about code generation?

Hm… ok so depending on your knowledge this might go over your head:
Python is an interpreter language, meaning there is a program running in the background, that takes the code your write and turns it into something the computer can understand (which at the very core is binary, though there are a couple layers of languages inbetween).
The Python interpreter itself is a program written in C.
Now the code you write is just plain text - only if given to an interpreter will the Python code actually be executed.

The point of an interpreter is, if it runs, you can give additional code to it. That is the “runtime” - the time at which the interpreter is running. In order to run, the interpreter has to shove all the data you want it to use into the RAM and as such, you can actually change (almost) EVERYTHING at runtime with similar commands as you do when writing code. Only difference is, you need to understand how to adress things and what you want to change.

However Python especially is meant to make coding easy. So the interpreter will allow you to override anything it has currently around. This includes overriding certain keywords and then breaking your program because suddenly things mean something else.

This is most commonly used in “Notebook”-like IDEs, where the code is seperated into cells and you change, alter and delete single cells and then run whatever code is in there to have the interpreter update.

If you create a class and then during runtime tell the interpreter to add or delete a method from that class it will happily do this → then the class will now (not) have this method. Any piece of code that relies on this class will now either have a new method or might break.

This cannot be done in compiler-languages, because those are turned into self-sufficient programs with fixed code.

1 Like

thanks for the easy explanation, I really understand it very well
there is any easy example of coding implementation of this in python

thanks, buddy, that is what I am looking for

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.