Jump to content

Just finished watching your first Python episode I have a couple of comments I use a free pro...


G+_Russ DiBennetto
 Share

Recommended Posts

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

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

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

 Share

×
×
  • Create New...