New to Python here - coming from Perl, so have mercy If I'm asking perl-ish things.
I am trying to extend the functionality of an existing Python class (svgpathtools) via an additional module.
In other words, I would like to have in one file somewhere (AKA the module providing the extension):
def foo(path_a, path_b):
d=0
for t in range(0, 101, 1):
d = d + complex_distance(path_a.point(t / 100), path_b.point(t / 100))
return d / 100
setattr(svgpathtools.Path, 'foo', foo)
and then in the file using the extension
be able to do something like this:
import svgpathtools.foo
some_path.foo(some_other_path)
I'd like to know:
- how to name/where to save the file extending the svpathtools module (i.e.: what's the mapping between module name and file name)
- what should it look like in order to monkey-patch the svgtools methods
My biggest problem is finding out what this kind of stuff is called - so I can do my own googling. Full explanations are appreciated, but pointers for further research are enough for me to get going.