<div><div class="gmail_quote">2009/9/2 Chris Rebert <span dir="ltr"><<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin<<a href="mailto:quentin.lampin@gmail.com">quentin.lampin@gmail.com</a>> wrote:<br>
> Hi,<br>
> Being fairly new to Python, I'm trying to figure out the best way to use the<br>
> exec statement and I must admit that I am a bit lost.<br>
><br>
> Consider this case:<br>
> exec "print 'a'" in {},{}   [exp.1]<br>
> It means  that I'm (kindly) asking the interpreter to execute the code<br>
> string  "print 'a'" with empty globals and locals.<br>
> Considering that globals and locals are empty, I would expect [exp.1] to<br>
> raise an exception about 'print' not being known.<br>
<br>
</div>In Python versions prior to 3.0, print is a statement (like for,<br>
while, if, etc), not a function (note how you don't need parentheses<br>
when using it); so it doesn't matter whether the built-in functions<br>
are available or not, print will still work.<br>
<br>
Cheers,<br>
Chris<br>
<font color="#888888">--<br>
<a href="http://blog.rebertia.com" target="_blank">http://blog.rebertia.com</a><br>
</font></blockquote></div><br>Ok, thanks for the explanation.<div>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 </div>
<div>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".</div><div><br></div><div>Regards,</div><div>
Quentin<br><div class="gmail_quote"><br></div></div>
</div>