I've used the C api to write a method that can call any python module function. I would like to extend the interface to allow dynamically listing all python modules, and for a given module all functions, and for a given function all argument types and the return types if possible.<div>


<br></div><div>Starting with the modules, I came up with this bit of code:</div><div><br></div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">

from pkgutil import walk_packages;</blockquote><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">

modules=[]</blockquote><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">

modules = [modules.append(item[1]) for item in walk_packages()]</blockquote><div><br></div><div>I then took this to my various systems for testing. It works fine on OSX and one of my Ubuntu boxes, but two of the Ubuntu boxes fail, each with a different error message.  The failure is due to python importing every single module and some of the modules failing. One example is the UniConverter package - towards the end of __init__.py it calls sys.exit(0) which kills the interpreter completely. <br>
</div><div><br></div><div>I've spent a ton of time trying to rewrite walk_packages to be robust to failure, but so far without luck. Any advice is appreciated.</div><div><br></div><div>/Brian</div>