import cannot be used inside eval
阎兆珣
yanzhaoxun at greendh.com
Thu Feb 4 00:03:33 EST 2016
a = input("tell me which py to execute: ")
print(a)
print('import '+a)
print(type('import'+a))
eval('print(a)')
try:
eval('import '+a)
except Exception as e:
print('Error: ', e)
##while True:
## pass
@python 3.4.2
this code attempts to run a .py file that user specifies.
eval() does fine with print() command
but fails to call import command
Is it a but or a taboo?
Thanks
Zhaoxun Yan
Option Product Manager
Gelin Dahua Futures Co.Ltd
T: +86 10 56711783
More information about the Python-list
mailing list