5.2.2 Null Properties and Empty Lists

When an instance has a null property or an empty list, the instance in Suds removes the property. For example, when instance has no name:

instance.name = None

the Suds instance removes the name property. Therefore, in order to check the name property, you must first check that the instance actually contains the property:

if 'name' in instance and instance.name == 'foo':
      # do something

Equally, empty lists result in a similar behavior, where Suds removes the property. In order to iterate on a property that contains a list, you must first check that the property exists:

if 'ethernetPortIds' in server:
      for ethernet_port_id in server.ethernetPortIds:
      # do something

Attempting to iterate through a property containing an empty list results in an exception, as the property is removed from the instance. As a result, it is not a good idea to simply attempt to iterate on a property expecting it to be available:

for ethernet_port_id in server.ethernetPortIds:
      # do something

In the example above, if the ethernetPortIds property is an empty list, Suds does not attach it as a property of the server instance. The result is an exception similar to the following:

AttributeError: server instance has no attribute ‘ethernetPortIds’ exception.