How to loop over the API for creating a generative code? i'd like to experiment with code generation with the blender API, but i first need to understand how i could loop over the API within my code 

for example bpy.context.object have tons of properties, we can naturally see those properties within the console autocomplete or within the Otuliner Data Api





let's take a modifier for example. (here above)
we can clearly see from the outlined or console that this 'Array' modifier have many properties (or functions)

i'd like to know how i can print each property module followed by the value assigned. 
something like so:

import bpy 

obj = bpy.data.objects['my_object']
mod = obj.modifiers['Array']

print('Properties of Array modifier:')

for modules,value in mod:

   print(f"property {module} : {value}"


i already saw this kind of solution used before, but it seemed to only work with bpy and bpy.utils

import pkgutil
import bpy
import email

package = bpy.utils
prefix = package.__name__ + "."
for importer, modname, ispkg in pkgutil.iter_modules(package.__path__, prefix):
    print("Found submodule %s (is a package: %s)" % (modname, ispkg))
You can take advantage of the dir() method in python to access "public" attributes of any object. You can use it for each modifier in the selected object :

import bpy

obj = bpy.context.object

for mod in obj.modifiers:
    print(mod.name, 'Modifier')
    for attr in dir(mod)[4::]:  # We skip the first 4 attributes which are internal
        print('  ', attr, ' --&gt; ', getattr(mod, attr))


Exemple with an object with an 'Array' and a 'Curve' modifier :