G+_Russ DiBennetto Posted April 4, 2014 Share Posted April 4, 2014 Just finished watching your first Python episode. I have a couple of comments. I use a free product on my windows machine called PyScripter 2.5.xx. It is an IDE that I have taken the code from, moved it to my Raspberry Pi and ran it through Python on the Raspberry Pi. I also have Python 2.5 loaded on my Windows system but find PyScripter easier to use. One other thing, you can use the Print statement in Python 2.x as a function too. Link to comment Share on other sites More sharing options...
G+_Wesley Kerfoot Posted April 4, 2014 Share Posted April 4, 2014 Correction: print is a function/procedure in python 3.x only. It's part of a statement in 2.x Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted April 4, 2014 Share Posted April 4, 2014 What you're probably thinking is that this: print(5) Works just fine on both 2 & 3. Looks like a function call, and in Python 3 it is. In Python 2, it's a print statement followed by (5), which is the number 5 in unnecessary parentheses. But you can do other function-y things with print in 3 that won't work in 2. Link to comment Share on other sites More sharing options...
G+_Russ DiBennetto Posted April 9, 2014 Author Share Posted April 9, 2014 Here is a short function I wrote in Python 2.5.x and run it on windows as well as linux running python 2.6.x and it works fine: def sortthelist(): fbuff = open("blacklist.dat" , "r" ) lines=fbuff.readlines() lines.sort() fbuff.close() fbuff = open("blacklist.dat" , "w" ) fbuff.writelines(lines) fbuff.close() print("Done") return 0 As you can see, you can use the print statement as a function in the earlier versions. Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted April 9, 2014 Share Posted April 9, 2014 This code does not use "print" as function. It is a statement, printing the value ("Done"). Try changing "return 0" to "return print" to see the difference. Link to comment Share on other sites More sharing options...
Recommended Posts