def itersubclasses(cls, _seen=None):
 if (not isinstance(cls, type)):
  raise TypeError('itersubclasses must be called with new-style classes, not {:.100r}'.format(cls))
 if (_seen is None):
  _seen = set()
 try:
  subs = cls.__subclasses__()
 except TypeError:
  subs = cls.__subclasses__(cls)
 for sub in sorted(subs, key=operator.attrgetter('__name__')):
  if (sub not in _seen):
   _seen.add(sub)
   (yield sub)
   for sub in itersubclasses(sub, _seen):
    (yield sub)

def itersubclasses ( cls , _seen = None ) : if ( not isinstance ( cls , type ) ) : raise TypeError ( 'itersubclasses must be called with new-style classes, not {:.100r}' . format ( cls ) ) if ( _seen is None ) : _seen = set ( ) try : subs = cls . __subclasses__ ( ) except TypeError : subs = cls . __subclasses__ ( cls ) for sub in sorted ( subs , key = operator . attrgetter ( '__name__' ) ) : if ( sub not in _seen ) : _seen . add ( sub ) ( yield sub ) for sub in itersubclasses ( sub , _seen ) : ( yield sub )
itersubclasses generator over all subclasses of a given class .