Re: 'psyco' problem

From: Hannu Kankaanp?? (hanzspam_at_yahoo.com.au)
Date: 10/10/04

  • Next message: Paul: "Re: integer type conversion problem/question"
    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.


  • Next message: Paul: "Re: integer type conversion problem/question"

    Relevant Pages

    • Re: 2s complement conversion. Is this right?
      ... It works similar to the way Python ... this version without Psyco is as fast Bob's version with Psyco! ... from struct import Struct ... def from3Bytes: ...
      (comp.lang.python)
    • Re: 2s complement conversion. Is this right?
      ... It works similar to the way Python ... this version without Psyco is as fast Bob's version with Psyco! ... from struct import Struct ... def from3Bytes: ...
      (comp.lang.python)
    • Re: Noob questions about Python
      ... Python because I want to teach myself a more powerful and broad ... now to remove all those intermediate lists you construct. ... def bin2dec: ... use Psyco and a more verbose version. ...
      (comp.lang.python)
    • psyco problem
      ... def main: ... ./tp.py:7: warning: eval/execfilecannot see the locals in functions ... bound by Psyco; consider using evalin its two- or three-arguments form ...
      (comp.lang.python)
    • Re: Linux-Signal VS QT
      ... import sys ... import psyco ... def sig_handler: ... The problem is that Python only delivers the signal when the interpreter is ...
      (comp.lang.python)