On Wednesday, November 27, 2013 9:09:32 PM UTC+1, Ned Batchelder wrote:
> I hope you aren't trying to prevent malice this way: you cannot examine
> a piece of Python code to prove that it's safe to execute.
No worry. Whoever has access to modifying those configuration files
can cause a mess in a
On Wed, 27 Nov 2013 11:40:52 -0800, magnus.ly...@gmail.com wrote:
> What I'm really after, is to check that python expressions embedded in
> text files are: - well behaved (no syntax errors etc) - don't
> accidentally access anything it shouldn't - I serve them with the values
> they need on execu
On 11/27/13 3:44 PM, Chris Kaynor wrote:
On Wed, Nov 27, 2013 at 12:09 PM, Ned Batchelder mailto:n...@nedbatchelder.com>> wrote:
* Is there perhaps a better way to achieve what I'm trying to do?
What I'm really after, is to check that python expressions
embedded in text
On Wed, Nov 27, 2013 at 12:09 PM, Ned Batchelder wrote:
> * Is there perhaps a better way to achieve what I'm trying to do?
>>
>> What I'm really after, is to check that python expressions embedded in
>> text files are:
>> - well behaved (no syntax errors etc)
>> - don't accidentally access anythi
On Nov 27, 2013 2:11 PM, "Ned Batchelder" wrote:
>
> On 11/27/13 2:40 PM, magnus.ly...@gmail.com wrote:
>>
>> So, in the case of "a.b + x" I'm really just interested in a and x, not
b. So the (almost) whole story is that I do:
>>
>> # Find names not starting with ".", i.e a & b in "a.c + b"
>
On 11/27/13 2:40 PM, magnus.ly...@gmail.com wrote:
When I run e.g. compile('sin(5) * cos(6)', '', 'eval').co_names, I get
('sin', 'cos'), which is just what I expected.
But when I have a list comprehension in the expression, I get a little surprise:
compile('[x*x for x in y]', '', 'eval').co_
When I run e.g. compile('sin(5) * cos(6)', '', 'eval').co_names, I get
('sin', 'cos'), which is just what I expected.
But when I have a list comprehension in the expression, I get a little surprise:
>>> compile('[x*x for x in y]', '', 'eval').co_names
('_[1]', 'y', 'x')
>>>
This happens in Pyth