Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clone a module and make changes to the copy

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?

like image 708
Matt Joiner Avatar asked Sep 20 '11 09:09

Matt Joiner


1 Answers

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.

like image 120
S.Lott Avatar answered Oct 16 '22 01:10

S.Lott