... if trueKey != "": modObj = pkgDict[trueKey] if modObj.__dict__.haskey(className): return modObj.__dict__[className] else: return None else: return None
In above example, two else conditions are unnecessary and messy. Concise version,
... if trueKey != "": modObj = pkgDict[trueKey] if modObj.__dict__.haskey(className): return modObj.__dict__[className] return None