brisket451
Posts: 1
Joined: Sun Jan 31, 2016 10:10 pm

Learning Python

Sat Feb 13, 2016 4:48 am

Does anyone have any good books or resources for someone who is interested in learning Python. I don't really have any programming experience right now.

MarsLoucetios
Posts: 19
Joined: Sat Jan 09, 2016 11:01 pm

Re: Learning Python

Sat Feb 13, 2016 5:33 am

I'm watching these videos right now Introduction to Programming with Python. You don't need Microsoft Visual Studio but if you'd like to try it, there's a free community version here Visual Studio Community. It's extremely advanced but doesn't work on Linux so I just use Python IDLE.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Learning Python

Sat Feb 13, 2016 5:52 am

brisket451 wrote:Does anyone have any good books or resources for someone who is interested in learning Python.
The problem is that python has bifurcated into 2.7.x and 3.x branches. Because you are learning, you'll wanted to learn 3.x but when you google for answers, a lot of stuff will be 2.7. Just know that and be ready to deal with the reality that there will be differences and you'll have to make often only small changes to get it to work on 3.x.

tech-mech
Posts: 114
Joined: Sun Feb 23, 2014 9:51 pm
Location: Portland, Oregon USA
Contact: Yahoo Messenger

Re: Learning Python

Sat Feb 13, 2016 6:52 am

I have several free PDFs (from the net) on Python. One is for those without a programming background.

stevech
Posts: 144
Joined: Sun Jul 15, 2012 11:53 pm

Re: Learning Python

Sun Feb 14, 2016 12:29 am

Beginner should learn Python 2.7 on a PC well before doing so on an RPi.
Learn by example - good code from others.

Lots of online tutorials.
Books:
Beginning Python, from novice to professional. 2nd edition. Magnus Lie Hetland. Apress.
Python Phrasebook (a reference manual). Brad Dayley. Sams Publishing

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: Learning Python

Sun Feb 14, 2016 12:31 am

stevech wrote:Beginner should learn Python 2.7 on a PC well before doing so on an RPi.
Learn by example - good code from others.

Lots of online tutorials.
Books:
Beginning Python, from novice to professional. 2nd edition. Magnus Lie Hetland. Apress.
Python Phrasebook (a reference manual). Brad Dayley. Sams Publishing
Totally disagree. 2.7 is a dying art. Python 3 is the future and that's what you should learn. The Pi was made for learning to program. The Python resources dedicated to Pi users on the main website (which is where you should start) are amazing. Python is platform independent so any code you Google will work on the Pi. Who needs a PC when you have a Pi?
There are 10 types of people: those who understand binary and those who don't.

MarsLoucetios
Posts: 19
Joined: Sat Jan 09, 2016 11:01 pm

Re: Learning Python

Sun Feb 14, 2016 2:02 am

Beginning Python, from novice to professional. 2nd edition. Magnus Lie Hetland. Apress.
Cool. I've already started reading it.

User avatar
Douglas6
Posts: 4668
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Learning Python

Sun Feb 14, 2016 2:14 am

stevech wrote:Beginner should learn Python 2.7 on a PC well before doing so on an RPi.
Wrong.
kusti8 wrote:The Pi was made for learning to program
Right.

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Learning Python

Sun Feb 14, 2016 7:29 am

When I started learning python, I learnt python 2 but only because that was driven by necessity: I needed to write some specific addons for xbmc (now Kodi) and scripts had to be python 2.

If there's no specific reason to use python 2 (and I can't think of many) then, I agree, I would start with python 3.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

stevech
Posts: 144
Joined: Sun Jul 15, 2012 11:53 pm

Re: Learning Python

Sun Feb 14, 2016 7:34 am

Douglas6 wrote:
stevech wrote:Beginner should learn Python 2.7 on a PC well before doing so on an RPi.
Wrong.
kusti8 wrote:The Pi was made for learning to program
Right.

"wrong"... per you. My recommendation is mine. You have your own opinion.

gkreidl
Posts: 5950
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Learning Python

Sun Feb 14, 2016 8:47 am

stevech wrote:
Douglas6 wrote:
stevech wrote:Beginner should learn Python 2.7 on a PC well before doing so on an RPi.
Wrong.
kusti8 wrote:The Pi was made for learning to program
Right.

"wrong"... per you. My recommendation is mine. You have your own opinion.
1) It didn't sound like an opinion but as an advice (or even fact).
2) It's completely contrary to what the the Foundation is trying to do.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
croston
Posts: 699
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: Learning Python

Sun Feb 14, 2016 9:51 am

stevech wrote:Beginner should learn Python 2.7 on a PC well before doing so on an RPi.
Wrong wrong wrong! I do not normally feed the trolls but here is some food for thought:

I started to learn Python with version 1.6 in 2001 when Python 2.0 was available. Knowing that old version is not much use now. Python 3 was released in 2008 and is the recommended version to learn. All the Foundation resources use Python 3. Why would you want to learn something that is rapidly becoming obsolete with minimal support in favour of a newer version?

hippy
Posts: 5326
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Learning Python

Sun Feb 14, 2016 3:33 pm

croston wrote:Why would you want to learn something that is rapidly becoming obsolete with minimal support in favour of a newer version?
Perhaps because Python 2.7 is so much quicker to execute on a Pi than Python 3.4 ?

I have a some Python code which is version agnostic which does string processing, tokenising source files, and runs quickly enough on my PC. As it is actual 'real world code' I tested that on my 900MHz Pi B+, reading 3,000 lines of source code while creating no output files and also when generating 1MB of output files -

Code: Select all

                  PC 2.7.6   Pi 2.7.9   Pi 3.4.2

No file output     0.389s     3.371s     4.277s
With file output   0.842s     8.986s    12.733s
That's quite interesting. The Pi is about 10 times slower than the PC which is in line with most rule of thumb expectations, but the exact same code using Python 3 takes at least 25% longer than Python 2, and takes 42% longer when creating output files.

That though is implementation difference, not language difference. I don't think there is that much difference in learning either 2.7 or 3.4; they are pretty much the same language as each other with just a few differences. It's not so much learning one or the other, but being more comfortable and familiar with either.

And, because of that huge commonality in the two, I would not classify 2.7 as becoming obsolete or only having minimal support.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Learning Python

Sun Feb 14, 2016 4:58 pm

hippy wrote:
croston wrote:Why would you want to learn something that is rapidly becoming obsolete with minimal support in favour of a newer version?
Perhaps because Python 2.7 is so much quicker to execute on a Pi than Python 3.4 ?
What's the joke about optimising Python? Oh, your code is 50 times slower than Java, optimise it, now it's 47 times slower.
And, because of that huge commonality in the two, I would not classify 2.7 as becoming obsolete or only having minimal support.
More of the internecine battles of the pythonistas, the 2.7 against the 3.x, muskets at the ready, bayonets fixed! Although I can't tell you how fast it is, I wonder if just ignoring those wars and using Hy (a Lisp for Python) makes sense. You can't use 3.x features if it is running it under 2.7, but at least you don't have to learn how to print using two different syntaxes and otherwise can run under the python that makes sense at the moment. And when you google for answers, you won't get ones for 2.7 version, you won't get anything.

DonnieMarco
Posts: 5
Joined: Sun Feb 14, 2016 4:11 pm

Re: Learning Python

Sun Feb 14, 2016 5:28 pm

I have just started myself again after several failed attempts with highly recommended books that really only describe the vocabulary of the language . But after doing the 'programming for everyone ' on the Coursera website I am now absolutely loving it.

User avatar
jojopi
Posts: 3074
Joined: Tue Oct 11, 2011 8:38 pm

Re: Learning Python

Sun Feb 14, 2016 11:12 pm

Python 3 is a better language for beginners. Examples:

Code: Select all

>>> 1/2
0.5

>>> 'háček'
'háček'

>>> input("what is your name? ")
what is your name? bob
'bob'
Compared to Python 2:

Code: Select all

>>> 1/2
0

>>> 'háček'
'h\xc3\xa1\xc4\x8dek'

>>> input("what is your name? ")
what is your name? bob
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in <module>
NameError: name 'bob' is not defined

User avatar
Douglas6
Posts: 4668
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Learning Python

Mon Feb 15, 2016 12:17 am

Hmm, that may be stacking the deck just a bit. The most important thing for beginners to know is that there ARE some small (and not so small) differences between Python 2 and 3.

Return to “Python”