Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: eval( 'import math' ) Date: Thu, 4 Feb 2016 07:30:14 -0700 Lines: 16 Message-ID: References: <298169014.1288190.1454592838187.JavaMail.root@wmthree-11> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de zaa71g5GWbeZc/e9iBKakwIs1OzJ+O3abtfPenvmbqew== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python': 0.10; 'thu,': 0.15; '2016': 0.16; 'eval': 0.16; 'evaluates': 0.16; 'executed.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'runtime.': 0.16; 'statement.': 0.16; 'subject:import': 0.16; 'wrote:': 0.16; 'string': 0.17; 'input': 0.18; 'trying': 0.22; 'am,': 0.23; 'feb': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; 'module': 0.25; 'command': 0.26; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'code': 0.30; 'though,': 0.32; 'problem': 0.33; 'that,': 0.34; 'received:google.com': 0.35; 'skip:i 20': 0.36; 'instead': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'secure': 0.60; 'more': 0.63; 'necessarily': 0.63; 'transfer': 0.73; 'discovered': 0.83; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=DZNawzcogMxoUm924phDNK0spn67adXOaOvfo/IAIQM=; b=DtyaYE4YQyyd7aXpZFgnIidVEBSKWWvilsTJoeL3DEbdsA5uUQx2b7RoDuzviXK+rh AF/gLKsAYHkMLwYrWSNZuIbR71m/fPOu7EAvD845dieP529E9LtPa29ARUfoRO+SY8nT nClbEk0A+HL8ph+YX2CuVd/iw1SpTEp2dyUWgrTuWenyMcR/FyWzgIiYDPIRhM5SZZhq EgOmJcK9PIJ7fbx2wnu9mXIud1oNI81hNiiMmPxp49iCSjwhCjdkLsswvVNomwJhWboX a8EH2CSELlWSSl89GhISuH30GBjPlkwucRltUGlcDqjzasn0yhQOpMji+0aE7SgoWMU4 I6VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=DZNawzcogMxoUm924phDNK0spn67adXOaOvfo/IAIQM=; b=OcRACzH2exl7qTsju7vvJIzKWGFI4EdzQZNFyD2Ihw1LFSRx4Bn/I9jLbCBa+KyYv/ Aq2bx8gmuekqIiVS0gQQ6AtwoaVfMUGS0kqodFNJ+e2PAT8jvOUaAWh/1ocfNnsodMTT z7JQKdtB0NzWq82UtXitIyMqKd1rqzjAsoJd4q8PiV/TNiCwoEG99aqj1L8BmWzqwKPf BKaN5sN0bjuNyG+8VqpPPe96wSvLWcLZC79zM4px3swMxooB9LKPDp9Pr/R4HgZWHxmG bmUhw3/TlMf91rWXC/qsUfLrS4yhF1XjyQ0nj2dMcq6FesLJ+6YesPNvDDbRQ/NX52zd KVdQ== X-Gm-Message-State: AG10YOQF3dYXN+9GgiJndAN6+kLOupWDeehTa9N9SR0QrIm2qTHnJ5EfCrYbedwmXSUHKZDeSAN2taPhPLVTvw== X-Received: by 10.50.61.177 with SMTP id q17mr9390781igr.68.1454596254231; Thu, 04 Feb 2016 06:30:54 -0800 (PST) In-Reply-To: <298169014.1288190.1454592838187.JavaMail.root@wmthree-11> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc1 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102496 On Thu, Feb 4, 2016 at 6:33 AM, =E9=98=8E=E5=85=86=E7=8F=A3 wrote: > Excuse me for the same problem in Python 3.4.2-32bit > > I just discovered that 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.