def import_class line if not isinstance line str return line print imp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
def import_class(line):
if not isinstance(line, str):
return line
print 'imp'
line = line.split('.')
return getattr(__import__('.'.join(line[:-1])),line[-1])
def geter_class(class_line):
def f_get():
v = import_class(class_line)
globals()['class_line'] = v
return v
return f_get
gg = geter_class('datetime.datetime')
print gg()
print gg()