2009/9/2 Chris Rebert <c...@rebertia.com> > On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin<quentin.lam...@gmail.com> > wrote: > > Hi, > > Being fairly new to Python, I'm trying to figure out the best way to use > the > > exec statement and I must admit that I am a bit lost. > > > > Consider this case: > > exec "print 'a'" in {},{} [exp.1] > > It means that I'm (kindly) asking the interpreter to execute the code > > string "print 'a'" with empty globals and locals. > > Considering that globals and locals are empty, I would expect [exp.1] to > > raise an exception about 'print' not being known. > > In Python versions prior to 3.0, print is a statement (like for, > while, if, etc), not a function (note how you don't need parentheses > when using it); so it doesn't matter whether the built-in functions > are available or not, print will still work. > > Cheers, > Chris > -- > http://blog.rebertia.com >
Ok, thanks for the explanation.I'm really confused with print being a statement but it's seems that I won't have to put too much effort on understanding why since 3.0 states the contrary. :p By the way, could you suggest me a link that explains why 3.0 changed this. It might provide some material to understand the pros and cons of "function statements". Regards, Quentin
-- http://mail.python.org/mailman/listinfo/python-list