def import_item(name):
 parts = name.rsplit('.', 1)
 if (len(parts) == 2):
  (package, obj) = parts
  module = __import__(package, fromlist=[obj])
  try:
   pak = getattr(module, obj)
  except AttributeError:
   raise ImportError(('No module named %s' % obj))
  return pak
 else:
  return __import__(parts[0])

def import_item ( name ) : parts = name . rsplit ( '.' , 1 ) if ( len ( parts ) == 2 ) : ( package , obj ) = parts module = __import__ ( package , fromlist = [ obj ] ) try : pak = getattr ( module , obj ) except AttributeError : raise ImportError ( ( 'No module named %s' % obj ) ) return pak else : return __import__ ( parts [ 0 ] )
import and return bar given the string foo .