It's easier to use `getattr`:  `if getattr(child_module, 'category') == submodule_type:`

getattr returns None if the attribute doesn't exist.  Since submodule_type isn't None, this does the same as the code you have.