On Tuesday 01 September 2009 11:32:29 Steven D'Aprano wrote:
> Possibly there is a way to have a thread halt itself after a certain
> amount of time? I'm not an expert on threads, I've hardly ever used them.
Not automagically, as far as I can see.
You are on your own if you want to somehow kill a
On Sep 1, 11:32 am, Steven D'Aprano
wrote:
> > But I don't quite understand why is it security
> > risk. How is it different to run:
> > exec 'format(your_hdd)'
> > than:
> > /bin/python format.py
> > ?
>
> It's not different. But read what I said -- "if the string is coming from
> an UNTRUSTED so
On Tue, 01 Sep 2009 01:34:33 -0700, Ecir Hana wrote:
>> You can copy the parts of the current scope into the namespace you pass
>> to exec, then later copy the revised values out again.
>>
>> But are you sure you really want to take this approach? exec is up to
>> ten times slower than just execut
On Sep 1, 5:31 am, Steven D'Aprano
wrote:
> But are you sure you really want to take this approach? exec is up to ten
> times slower than just executing the code directly.
Oh, you mean because of parsing and compiling? But otherwise it's as
fast as regular python? That's perfectly ok.
Or maybe
On Sep 1, 5:31 am, Steven D'Aprano
wrote:
>
> You can pass in a global and local namespaces to exec as arguments:
>
> >>> x = 4
> >>> ns = {'x': 4}
> >>> exec "x += 1" in ns
> >>> x
> 4
> >>> ns['x']
>
> 5
>
> See the docs for details.
Thanks! This is very useful!
> You can copy the parts of the
On Tue, Sep 1, 2009 at 9:29 AM, Ecir Hana wrote:
> - if I understood it correctly defining a function in the string and
> exec-ing it created the function in current scope. This is something I
> really don't want
>
Oops, missed that point.
May I ask what is there you don't want, and what about
I'm afraid I'm not much of a help here, but was there any reason you didn't
want to wrap those "string functions" inside a function, and just call the
function?
Cheers,
-Xav
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 31 Aug 2009 16:29:45 -0700, Ecir Hana wrote:
> Hello,
>
> please, how to execute a python script stored as a string? But let me
> impose several limitations, so simple "exec" wont work:
>
> - if I understood it correctly defining a function in the string and
> exec-ing it created the fun
Hello,
please, how to execute a python script stored as a string? But let me
impose several limitations, so simple "exec" wont work:
- if I understood it correctly defining a function in the string and
exec-ing it created the function in current scope. This is something I
really don't want
- sim