<br><br><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><div></div><div class="h5">On Wed, Sep 2, 2009 at 1:13 PM, Quentin Lampin<<a href="mailto:quentin.lampin@gmail.com">quentin.lampin@gmail.com</a>> wrote:<br>
> 2009/9/2 Chris Rebert <<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>><br>
>><br>
>> On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin<<a href="mailto:quentin.lampin@gmail.com">quentin.lampin@gmail.com</a>><br>
>> wrote:<br>
>> > Hi,<br>
>> > Being fairly new to Python, I'm trying to figure out the best way to use<br>
>> > 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>
>> 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>
>> --<br>
>> <a href="http://blog.rebertia.com" target="_blank">http://blog.rebertia.com</a><br>
><br>
> Ok, thanks for the explanation.<br>
> I'm really confused with print being a statement but it's seems that I won't<br>
> have to put too much effort on understanding why since 3.0 states the<br>
> contrary. :p<br>
> By the way, could you suggest me a link that explains why 3.0 changed this.<br>
> It might provide some material to understand the pros and cons of "function<br>
> statements".<br>
<br>
</div></div><a href="http://www.python.org/dev/peps/pep-3105/" target="_blank">http://www.python.org/dev/peps/pep-3105/</a> (PEP 3105 -- Make print a function)<br>
<a href="http://mail.python.org/pipermail/python-dev/2005-September/056154.html" target="_blank">http://mail.python.org/pipermail/python-dev/2005-September/056154.html</a><br>
<div><div></div><div class="h5"><br>
Cheers,<br>
Chris<br>
--<br>
<a href="http://blog.rebertia.com" target="_blank">http://blog.rebertia.com</a><br>
</div></div></blockquote></div><br><br clear="all">Thanks a lot Chris!<div><br></div><div>Quentin</div>