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


Groups > comp.lang.python > #102496 > unrolled thread

Re: eval( 'import math' )

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2016-02-04 07:30 -0700
Last post2016-02-04 07:30 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: eval( 'import math' ) Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-04 07:30 -0700

#102496 — Re: eval( 'import math' )

FromIan Kelly <ian.g.kelly@gmail.com>
Date2016-02-04 07:30 -0700
SubjectRe: eval( 'import math' )
Message-ID<mailman.64.1454596256.30993.python-list@python.org>
On Thu, Feb 4, 2016 at 6:33 AM, 阎兆珣 <yanzhaoxun@greendh.com> wrote:
>    Excuse me for the same problem in Python 3.4.2-32bit
>
>    I just discovered that <eval()> function does not necessarily take the
>    string input and transfer it to a command to execute.
>
>    So is there a problem with my assumption?

eval evaluates an expression, not a statement. For that, you would use exec.

If you're just trying to import though, then you don't need it at all.
Use the importlib.import_module function instead to import a module
determined at runtime. This is more secure than eval or exec, which
can cause any arbitrary Python code to be executed.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web