libvirt functions discovery in python

The C API of libvirt is well documented and one can easily understand how the virNetworkGetDHCPLeases function should be called. However, it is less straightforward with the python libvirt module despite the libvirt development guide. The example from the sources shows the corresponding python method is DHCPLeases

import libvirt
conn = libvirt.open("qemu:///system")
net = conn.networkLookupByName("default")
leases = net.DHCPLeases()

But how did virNetworkGetDHCPLeases become DHCPLeases?

There is unfortunately no reference documentation and, as the HACKING file explains, the function names are generated from the C headers and transformed in non trivial ways, to make them shorter. In addition some functions are not implemented. To sort this out the pydoc tool should be used:

$ pydoc libvirt.virNetwork
libvirt.virNetwork = class virNetwork(builtins.object)
 |  libvirt.virNetwork(conn, _obj=None)
 |  
 |  Methods defined here:
 |  
 |  DHCPLeases(self, mac=None, flags=0)
 |      Returns a list of dhcp leases for interfaces connected to the given virtual network
 |  
 |  UUID(self)
 |      Extract the UUID unique Identifier of a network.
 |  
 |  UUIDString(self)
 |      Fetch globally unique ID of the network as a string.
 |  
 |  XMLDesc(self, flags=0)
...

Although the documentation is present, it is often terse and one should lookup the corresponding C documentation instead. For instance,

$ pydoc libvirt.virNetwork
...
 |  update(self, command, section, parentIndex, xml, flags=0)
 |      Update the definition of an existing network, either its live
 |      running state, its persistent configuration, or both.
 | 

Is less informative than the virNetworkUpdate C function documentation.