Skip to content

Instantly share code, notes, and snippets.

@jgillis
Last active December 17, 2015 22:39
Show Gist options
  • Save jgillis/5683620 to your computer and use it in GitHub Desktop.
Save jgillis/5683620 to your computer and use it in GitHub Desktop.
Method to print the class inheritance hierarchy
def print_subclasses(myclass, depth=0):
print (" " * depth) + " - " + myclass.__name__
for s in myclass.__subclasses__():
print_subclasses(s,depth=depth+1)
@jgillis
Copy link
Author

jgillis commented May 31, 2013

Example:

from casadi import *

print_subclasses(FX)

returns

 - FX
   - SXFunction
   - MXFunction
   - LinearSolver
     - SymbolicQR
     - LapackLUDense
     - LapackQRDense
     - CSparse
   - ImplicitFunction
     - NLPImplicitSolver
     - NewtonImplicitSolver
     - KinsolSolver
   - Integrator
     - RKIntegrator
     - CollocationIntegrator
     - SundialsIntegrator
       - CVodesIntegrator
       - IdasIntegrator
   - Simulator
   - ControlSimulator
   - NLPSolver
     - SQPMethod
     - SCPgen
     - IpoptSolver
     - KnitroSolver
     - WorhpSolver
   - QPSolver
     - NLPQPSolver
     - OOQPSolver
     - QPOasesSolver
     - CplexSolver
   - OCPSolver
     - DirectSingleShooting
     - DirectMultipleShooting
     - DirectCollocation
   - SDPSolver
     - DSDPSolver
   - ExternalFunction
   - Parallelizer
   - CFunction
     - PyFunction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment