Re: 'psyco' problem
From: Hannu Kankaanp?? (hanzspam_at_yahoo.com.au)
Date: 10/10/04
- Previous message: Andrew Dalke: "Re: xml file structure for use with ElementTree?"
- In reply to: Paulo da Silva: "'psyco' problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 10 Oct 2004 02:57:35 -0700
Paulo da Silva <psXdaXsilva@esotericaX.ptX> wrote in message news:<1097371920.617950@mystique.esoterica.pt>...
> When running the following program:
>
> #! /bin/env python
> # -*- coding: iso-8859-15 -*-
>
> import psyco
> psyco.full()
>
> def main():
> n=eval("123+456")
> print n
>
> if __name__ == "__main__":
> main()
>
>
> I got:
> ./tp.py:7: warning: eval()/execfile() cannot see the locals in functions
> bound by Psyco; consider using eval() in its two- or three-arguments form
> def main():
> 579
>
> What does this mean? Is there anything wrong?
>
> Thank you.
It means you can't do this if main() is bound by Psyco:
def main():
x=5
print eval("123+x")
because as the warning message says, Psycoed eval() cannot see the
locals (x here). And it suggest that you should consider using
eval() in its two- or three-arguments form, which is described
in the Python Library Reference. So with Psyco, you might use
y = 3
def main():
x=5
print eval("y+x", globals(), {'x':x})
But in your case, it of course doesn't matter because in
the expression 123+456 you aren't using any locals.
- Previous message: Andrew Dalke: "Re: xml file structure for use with ElementTree?"
- In reply to: Paulo da Silva: "'psyco' problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|