Python and learning programming

What version of Python comes with the Pi? I'm currently restarting programm ing using Python 3 on my craptop, and the book I've bought (called "Program ming for absolute beginners" or the like; it's been a long time since I did any programming, and I've never used an object-oriented language, except D elphi which is a Von Neumann language (Pascal) with an OO layer slapped on top of it) sadly turned out to be for an earlier version of Python, so the very first example gave a syntax error.

So, does the Pi come with an earlier Python, or will I have to get another book?

Reply to
Robert Baker
Loading thread data ...

Raspbian comes with both Python 2.x and Python 3.x. You get to choose. :)

Reply to
mick

On Fri, 15 Aug 2014 04:49:33 -0700 (PDT), Robert Baker declaimed the following:

The version will likely depend upon the distribution of the OS being installed (there are a few different OS variations). Most likely it will be something in the 2.5-2.7 style (I'd hope not as far back as a 2.4).

formatting link

Without seeing your code sample it is hard to tell if you were using

2.x on a 3.x, or a 3.x on a 2.x -- in 2.x, "print" is a language statement (no parens needed; but usually not harmful either) while in 3.x it has become a library function (so what is to be printed needs to have parens around it).
--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
Reply to
Dennis Lee Bieber

The Raspbian OS (the one most commonly used with the Pi) comes with both Python 2.7 and Python 3.2 installed.

The "python" and "idle" commands are used for Python 2.

The "python3" and "idle3" commands are used for Python 3.

Reply to
Dom

Type python to a shell. On startup, it tells you the version info.

On my system:

murray@pi1:~$ python Python 2.7.3 (default, Mar 18 2014, 05:13:23) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.

There are commands for python2 and python3. Python (without a 2 or 3) gets you the one your distro picks.

murray@pi1:~$ python3 Python 3.2.3 (default, Mar 1 2013, 11:53:50) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.

murray@pi1:~$ python2 Python 2.7.3 (default, Mar 18 2014, 05:13:23) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.

--
These are my opinions.  I hate spam.
Reply to
Hal Murray

I recently decided to try to switch to Python 3, but I found that there's still problems with tools and libraries, so I gave up and decided to wait another couple of years.

I'd recommend using your book and learn Python 2 for now. There aren't _that_ many differences with Python 3, so it wouldn't be too much trouble to switch at a later date.

Reply to
Dave Farrance

An examination of archive.raspbian.org shows these versions of python available: 2.6, 2.7, 3.2, 3.3, and 3.4.

Source:

formatting link

--
Consulting Minister for Consultants, DNRC 
I can please only one person per day. Today is not your day. Tomorrow 
 Click to see the full signature
Reply to
I R A Darth Aggie

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.