Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102468

import cannot be used inside eval

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From 阎兆珣 <yanzhaoxun@greendh.com>
Newsgroups comp.lang.python
Subject import cannot be used inside eval
Date Thu, 4 Feb 2016 13:03:33 +0800 (CST)
Lines 41
Message-ID <mailman.46.1454575313.30993.python-list@python.org> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset="utf-8"
X-Trace news.uni-berlin.de raqaBcTkP0l4lmF4Nu/QogNsxPnAS8qt1BsjcAaCdgXw==
Return-Path <yanzhaoxun@greendh.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.083
X-Spam-Evidence '*H*': 0.84; '*S*': 0.00; 'exception': 0.13; '.py': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:import': 0.16; "skip:' 40": 0.22; 'import': 0.24; 'command': 0.26; 'skip:" 20': 0.26; 'fine': 0.28; 'code': 0.30; 'to:name:python-list': 0.30; 'option': 0.31; 'run': 0.33; 'file': 0.34; 'but': 0.36; 'to:addr:python-list': 0.36; 'does': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'subjectcharset:utf-8': 0.71; '+86': 0.84; 'co.ltd': 0.84
X-263anti-spam RES:Ip;BIG:0;ABS:1;DNS:0;ATT:0;SPF:S;
X-MAIL-GRAY 0
X-MAIL-DELIVERY 1
X-ABS-CHECKED 1
X-SKE-CHECKED 1
X-RL-SENDER yanzhaoxun@greendh.com
X-FST-TO python-list@python.org
X-SENDER-IP 192.168.167.113
X-LOGIN-NAME wmsendmail@net263.com
X-UNIQUE-TAG <b56eb730567cee4923d51a86157722c3>
X-ATTACHMENT-NUM 0
X-SENDER yanzhaoxun@greendh.com
X-DNS-TYPE 0
X-Send-Individually 0
X-Reply-Previous-EmailId
X-Priority 3
X-Mailman-Approved-At Thu, 04 Feb 2016 03:41:48 -0500
X-Content-Filtered-By Mailman/MimeDel 2.1.21rc1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc1
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:102468

Show key headers only | View raw


   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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

import cannot be used inside eval 阎兆珣 <yanzhaoxun@greendh.com> - 2016-02-04 13:03 +0800

csiph-web