Being new to Python, but still unescapable, I'm stuck on this problem. What I'm trying to do is pass a string into the function to get it extend
ed.
Here is what I have:
def replace(source, destination):
local_source = src_tree.find("source")
local_destination = dest_tree.find("destination")
local_destination.extend(local_source)
replace(source=".//animal-list/dog", destination=".//animal-list/dog")
This piece of code will work if I don't place it in a function. But because I have hundreds of these "expend
" that I have to achieve, why not the good o' function calling.
Originally I have this, and it works as what I need:
src = src_tree.find('.//animal-list/dog')
dest = dest_tree.find('.//animal-list/dog')
dest.extend(src)
And what that would do is "replace" the dest
dog with src
dog. Works perfect, but I'm trying to make it into a function for easier use.
My question would be, what am I doing wrong in the function? Since it is tossing up a exception.
Traceback (most recent call last):
File "test.py", line 28, in <module>
replace(source=".//animal-list/dog", destination=".//animal-list/dog")
File "test.py", line 13, in replace
local_destination.extend(local_source)
AttributeError: 'NoneType' object has no attribute 'extend'