Is it possible to copy a module, and then make changes to the copy? To phrase another way, can I inherit from a module, and then override or modify parts of it?
To phrase another way, can I inherit from a module, and then override or modify parts of it?
Yes.
import module
You can use stuff from module
or override stuff in your script.
You can also do this to create a "derived" module.
Call this "module_2".
from module import *
Which imports everything. You can then use stuff from module
or override stuff in this new module, "module_2".
Other scripts can then do
import module_2
And get all the stuff from module modified by the overrides in module_2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With