def classTraverse(package, classFun, packageFun):
    """traverse package with classFun and packageFun."""
    for member in filter(lambda name: not re.match('__[^_]+__', name), dir(package)):
        print repr(member)
        try:
            memberObject = getattr(package, member)
            if isjpackage(memberObject):
                packageFun(memberObject)    # use packageFun to PyJavaPackage
                classTraverse(memberObject, classFun, packageFun)
            elif isjclass(memberObject):
                classFun(memberObject)      # use classFun to PyjavaClass
        except NoClassDefFoundError:
            print 'EXCEPTION: can\'t found package'
        except InstantiationException:
            print 'EXCEPTION: can\'t create package intance'
        except StringIndexOutOfBoundsException:
            print 'EXCEPTION: StringIndexOutOfBoundsException'
        except UnsatisfiedLinkError:
            print 'EXCEPTION: UnsatisfiedLinkError for package'
traverse package with classFun and packageFun.
recipes/Python/502222_Creating_javclass/recipe-502222.py