Many thanks for your reply, Greg.
I am using version 4.0.7 of KiCad.
I might have also added that I am using execfile() to run a .py file, rather than entering the code directly into the interpreter.
I tried the dir() command that you suggested and there is no GetNetsByNetcode attribute listed there.
I tried replacing the GetNetsByNetcode attribute with one that IS listed, namely GetNetCount, and IT WORKED!
Thank you, very much, for that.
Perhaps now I can move on to my next hurdle.