def class_for_name(class_name):
 tokens = class_name.split('.')
 if (len(tokens) > 1):
  package = '.'.join(tokens[:(-1)])
  class_name = tokens[(-1)]
  exec ('from %s import %s' % (package, class_name))
 return eval(class_name)

def class_for_name ( class_name ) : tokens = class_name . split ( '.' ) if ( len ( tokens ) > 1 ) : package = '.' . join ( tokens [ : ( - 1 ) ] ) class_name = tokens [ ( - 1 ) ] exec ( 'from %s import %s' % ( package , class_name ) ) return eval ( class_name )
given fully-qualified class name .