[EMAIL PROTECTED] wrote:

> This recipe fails when negative numbers are used.
> 
> safe_eval('(12, -12)')
> *** Unsafe_Source_Error: Line 1.  Unsupported source construct:
> compiler.ast.UnarySub
> 
> But, I think it could  be easily fixed for somebody who understands the
> script. 

I think that somebody could be you.

> Can somebody help. 

Start with

class SafeEval(object):
    # ...
    def visitUnarySub(self, node, **kw):
        return -node.expr.value

and then add some error handling.

Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to