How can I parse this correctly?

Mark Lawrence breamoreboy at yahoo.co.uk
Sun Apr 6 07:32:21 EDT 2014


On 06/04/2014 09:17, Chris Angelico wrote:
> On Sun, Apr 6, 2014 at 4:29 PM, Anthony Papillion <papillion at gmail.com> wrote:
>> No particular reason at all. I've Bern dabbling in Python for the last bit
>> and am just writing code based on the samples or examples I'm finding.  What
>> was the tipoff that this was not Python 3? Would there be a large difference
>> in this code if it was Python 3?
>
> The tip-off was that you have no parentheses around print's arguments.
> Behold the vast difference that told me which it was:
>
> # Python 2: print is a statement
> print int(row['YEAR'])
>
> # Python 3: print is a function
> print(int(row['YEAR']))
>
> So incredibly different :) But it's enough to show that you're on Python 2.
>
> ChrisA
>

I'd recommend using this import statement in Python 2 so you get used to 
print being a function.

from __future__ import print_function

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com





More information about the Python-list mailing list