[Tutor] Hello, and a newbie question

Dave Angel davea at davea.name
Wed Apr 17 00:17:21 CEST 2013


On 04/16/2013 05:47 PM, Andy McKenzie wrote:
> On Tue, Apr 16, 2013 at 5:31 PM, Dave Angel <davea at davea.name> wrote:
>
>>     <SNIP>
>>
>> To get 3.x functionality, you'd want to use
>>      from __future__ import print_function
>>
>> and I do not think that works in 2.6 or older versions.  It also can be
>> awkward even in 2.7 if you're mixing existing code with new print functions.
>>
>>
> That's good to know, since I hadn't run into it yet.
>
> So am I correct in understanding that I can just put the from __future__
> import print_function in each new 2.7 script, and get identical
> functionality to what happens in 3.x?  Or do I need to do that system-wide
> somehow?
>

Someone else may know if "identical" has some exceptions.  But as for 
where to put it, you'd need it for any module (including your own 
script) which is going to use the newer print() function.

And the nice thing is that the from-future directive is ignored in 3.x, 
so you don't have to remove it when you do progress.

-- 
DaveA


More information about the Tutor mailing list