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


Groups > comp.lang.python > #28154

Re: get return or locals from "exec" str in "environment"

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
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; 'exec': 0.07; 'any.': 0.09; 'oh,': 0.09; 'skip:# 30': 0.09; 'aug': 0.13; 'ignore': 0.13; 'both.': 0.16; 'duplicates': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'graceful': 0.16; 'perfect.': 0.16; 'threads': 0.16; 'wherein': 0.16; 'wrote:': 0.17; 'memory': 0.18; 'file.': 0.20; 'sort': 0.21; 'trying': 0.21; 'do.': 0.21; 'received:209.85.214.174': 0.21; '31,': 0.22; 'this:': 0.23; "i've": 0.23; 'feature': 0.24; 'header:In-Reply-To:1': 0.25; 'common': 0.26; 'am,': 0.27; 'disk': 0.27; 'executing': 0.27; 'message-id:@mail.gmail.com': 0.27; 'loads': 0.29; 'surprised': 0.29; "i'm": 0.29; 'usually': 0.30; 'fri,': 0.30; 'normally': 0.30; 'function': 0.30; 'code': 0.31; 'room': 0.32; 'running': 0.32; 'environment,': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'posting': 0.35; 'too.': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'subject:" ': 0.36; 'does': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'sure': 0.38; 'description': 0.39; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'space': 0.39; 'short': 0.39; 'header:Received:5': 0.40; 'real': 0.61; 'kind': 0.61; "you'll": 0.62; 'other.': 0.64; 'afraid': 0.66; 'unusual': 0.71; 'subject:get': 0.81; 'alternative.': 0.84; 'holes': 0.84; 'careful': 0.91; 'lucas': 0.93; 'room,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=UUARi3/hQnGnFLj1LQF5dh0eAIaH5TQs/bOYE7dU6l0=; b=RTSLfjK48Th48eD1HDu+eZviSIlFD/qhox14WLzXTNypzInVk/tREBgHtPp5ALqhIn TdoZ87R4Xsxjpob+BWQsHfZysmqHAijS2VUU/jSuNFsdjMUcfpNLRN0BWOUfwDBKtV9l N4BiWD7yDMUnqtTYmVRF6IFPIHa01YV0q9uk9NKUKBZ5xQxvDLZYLZpiyqiffYUOUtcK LcNyIRmZ+8Yb5oZFujn3m5j2wIunkwWjnkU/N1rv2LLx+el3XHBB9yWPOPMRjGO/Yd1M DCbMSwAqLmIvDYtIS2tZ96KNnGXu1goNXT9R9YC/sCjD1dVWPG99Rj27LTU9edmkDgl2 0sNw==
MIME-Version 1.0
In-Reply-To <1616cffa-23ea-4377-b415-fa143d0c5e5d@googlegroups.com>
References <5c488ca5-d730-40c4-b860-7a53201f21ae@googlegroups.com> <mailman.3987.1346365155.4697.python-list@python.org> <599e5709-22ab-4e85-8443-181a2ae19c17@googlegroups.com> <mailman.3991.1346366717.4697.python-list@python.org> <1616cffa-23ea-4377-b415-fa143d0c5e5d@googlegroups.com>
Date Fri, 31 Aug 2012 10:13:52 +1000
Subject Re: get return or locals from "exec" str in "environment"
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3995.1346372034.4697.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346372034 news.xs4all.nl 6918 [2001:888:2000:d::a6]:52996
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28154

Show key headers only | View raw


On Fri, Aug 31, 2012 at 9:54 AM, lucas <sjlukacs@gmail.com> wrote:
> oh, yeah that was perfect.  got it working and it is graceful too.  sorry about the double post, i thought i was only posting to this one.

Hehe, you're still posting to both. I don't see the duplicates myself,
but I'm sure others do. Just pick one and ignore the other.

> one final concern, if this code is running under a function in a multi-threaded, multi-session kind of environment, does exec cross threads or sessions?  like, i am afraid that i will get cross-over or bleeding into other threads or sessions.  does exec do that kind of common memory space wherein i have to be very very careful about executing such code and my daemon crashing or security holes and the like.

Not that I am aware of, and I would be extremely surprised if there
were any. But exec is not the sort of thing you'll normally want to
use. What are you trying to accomplish? There's usually an
alternative.

The only time I've used an exec-like feature is when I'm actually
writing something that loads code from the disk at run-time, such as
my MUD with room files that look like this:

@sdesc Short Description
@ldesc This is the long description of the room, blah blah
@cmds thwap #do_something_when_user_types_thwap()

VERY unusual sort of thing to do - having real code in a data file.

ChrisA

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


Thread

Re: get return or locals from "exec" str in "environment" Chris Angelico <rosuav@gmail.com> - 2012-08-31 08:19 +1000
  Re: get return or locals from "exec" str in "environment" lucas <sjlukacs@gmail.com> - 2012-08-30 15:25 -0700
    Re: get return or locals from "exec" str in "environment" Chris Angelico <rosuav@gmail.com> - 2012-08-31 08:45 +1000
      Re: get return or locals from "exec" str in "environment" lucas <sjlukacs@gmail.com> - 2012-08-30 16:54 -0700
        Re: get return or locals from "exec" str in "environment" lucas <sjlukacs@gmail.com> - 2012-08-30 16:56 -0700
        Re: get return or locals from "exec" str in "environment" lucas <sjlukacs@gmail.com> - 2012-08-30 16:56 -0700
        Re: get return or locals from "exec" str in "environment" Chris Angelico <rosuav@gmail.com> - 2012-08-31 10:13 +1000
      Re: get return or locals from "exec" str in "environment" lucas <sjlukacs@gmail.com> - 2012-08-30 16:54 -0700
  Re: get return or locals from "exec" str in "environment" lucas <sjlukacs@gmail.com> - 2012-08-30 15:25 -0700

csiph-web