User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

New to Python???

Fri Sep 30, 2016 2:31 am

I have never had the opertunity to play with Python, beings that I have always been a RISC OS user. Though now I am using Raspbian Linux more and more, so I would like to at least learn Python.

The trouble is that I have absolutely no clue as to where to begin. I am completely new to Python, have never done anything at all with Python, and am not even certain of what questions to ask.

I would like to learn to program in Python as a procedural language (not OO). I would like to learn how to use Python to take advantage of the RPi's features (GPIO, accelerated video [presumably through OpenGL ES], etc).

So where do I begin? What resources do I use?

And please, anything I did not think to ask

To make sure my understanding is correct:
Python is an interpreted language, correct?
Python is both a procedural and OO language, correct?
Python is meant to be as simple as structured BASIC, correct?
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

tom.slick
Posts: 190
Joined: Wed Jan 06, 2016 9:23 pm

Re: New to Python???

Fri Sep 30, 2016 3:22 am

Not being sarcastic, but googles links are a great starting points for learning python. Links 4 through 1 (in that order) are really good statring points for a begginer.
https://www.google.com/search?num=20&es ... M2W4kTrWtE

And to your direct questions.
Yes
Yes
And Yes

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: New to Python???

Fri Sep 30, 2016 4:10 am

tom.slick wrote:Not being sarcastic, but googles links are a great starting points for learning python. Links 4 through 1 (in that order) are really good statring points for a begginer.
https://www.google.com/search?num=20&es ... M2W4kTrWtE

And to your direct questions.
Yes
Yes
And Yes
Ok, I had always avoided google for anything programming related, as with most of what I do I end up having to wade through many pages of useless results to find one or two that are on point.

So I will google this one, thank you.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: New to Python???

Fri Sep 30, 2016 4:28 am

Thank you for those links. I am already going through them, though a lot of the stuff seems to assume a 4 year old (eg someone that is new to programming), I can bare with that.

Now I will just have to figure out what differences there are between Python 2 and Python 3, as the tutorials seem to target Python 3, and I would definitely use Python 2.

My goal in learning Python is to figure out rather or not it is the way to go. Is it better to use Python 2 on Linux and RISC OS, or is it better to use BBC BASIC V on RISC OS, and Brandy BASIC on Linux and other OS's?

That is a question I can not answer until I have a good working and experiential knowledge of Python.

I am also looking into Lua, and what ever others may be of good use. Even though not yet available for RISC OS, I am even looking into FreeBASIC (which is a nice compiled BASIC I may add).
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
bensimmo
Posts: 4183
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: New to Python???

Fri Sep 30, 2016 6:18 am

Why not just go with Python3 and leave Python2 behind. The Python website and documentation has the difference for each part iirc. Just remember Raspian is still behind at Python 3.4
While most beginner site are targeted at beginners, there is a good reason for that ;-)
It shouldn't take you long and no doubt you'll be better than mlst pretty quickly as you seem to have the time to invest.

On what os it better and whatever, only you can answer that for yourself. Many would say there is no point in using RiscOS let alone anything BASIC.

Search for python for experienced programmers and you may get some straight in there alternatives.

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

Re: New to Python???

Fri Sep 30, 2016 6:29 am

You are already a programmer so just forget all the courses etc. on the net. Just read the important chapters of the official documentation. For Python 2:
https://docs.python.org/2.7/
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
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: New to Python???

Fri Sep 30, 2016 6:44 am

bensimmo wrote:Why not just go with Python3 and leave Python2 behind. The Python website and documentation has the difference for each part iirc. Just remember Raspian is still behind at Python 3.4
While most beginner site are targeted at beginners, there is a good reason for that ;-)
It shouldn't take you long and no doubt you'll be better than mlst pretty quickly as you seem to have the time to invest.

On what os it better and whatever, only you can answer that for yourself. Many would say there is no point in using RiscOS let alone anything BASIC.

Search for python for experienced programmers and you may get some straight in there alternatives.
As stated I am attempting to learn Python 2 because there is Python 2.7.x for RISC OS, Raspbian, ReactOS, and DOS.

I already know which OS's I like, I am just looking into which language's are best to use that will work with little to no modification on both RISC OS and Raspbian. And I have to give Python its fair shake.

So far the only thing I am having trouble figguring out is how to do absolute address pointers in Python, one of the most important things in any programming language, yet not documented that I can find.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: New to Python???

Fri Sep 30, 2016 6:44 am

gkreidl wrote:You are already a programmer so just forget all the courses etc. on the net. Just read the important chapters of the official documentation. For Python 2:
https://docs.python.org/2.7/
Thank you for that. That is indeed helpful. Though it still lacks information about address pointers, this is such an important part of any programming language, why do they make it difficult to find in the Python documentation?
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

tom.slick
Posts: 190
Joined: Wed Jan 06, 2016 9:23 pm

Re: New to Python???

Fri Sep 30, 2016 6:46 am

Sorry if the examples are to basic. But it's better to assume no knowledge then to assume some knowledge and confuse a "beginner" and start in the middle.

From your comments you seem to favor BASIC in one form or another. But once you get to know and use python you will find that it is the "GOTO" for basic scripting and quick prototyping. I loved BASIC at one time (30 years ago) and must admit that python made it easy to upgrade my skills. It was as simple as learning a new syntax. I tried FreeBASIC a few years back before I found python and liked it, but then I discovered python and haven't done a single thing in FreeBASIC since. It's more cross platform then any of the BASIC's. I wish is was more complete for RISC OS than it is, but that is another story.

Python 2 is the stable, reliable, and the goto version of python, and the version you should be using. Don't repeat that on this forum, most of the people here think python3 is the only choice (they come from a windows background and think version numbers mean something, watch someone will post a response to this and say that python3 is the only way to go). But with RISC OS python2 is your only choice so I don't think you need to worry about the bad advice to run python 3 because it is the latest and greatest, bad advice because you don't have the option to use python3 on RISC OS. For a beginner there are few differences to worry about between the two (print as function as an example). At the intermittent level then you will find a few differences that need to be worked with (example, missing modules).

Lua is okay, I've done a little with it, if you have good RISC OS support for lua then you might want to look into that as an alternative to python.

Best advice is to play with python and lua and see what suites your needs as something that is Linux, RISC OS compatible.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: New to Python???

Fri Sep 30, 2016 1:24 pm

How do you do pointers in Python? This is becoming frustrating.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

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

Re: New to Python???

Fri Sep 30, 2016 2:18 pm

DavidS wrote:How do you do pointers in Python? This is becoming frustrating.
Pointers are obsolete in Python; you can access any element of sequence types by indexing. If you want to have a more C-like behavior have a look at the at the cytypes module or at Cython.
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
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: New to Python???

Fri Sep 30, 2016 2:20 pm

gkreidl wrote:
DavidS wrote:How do you do pointers in Python? This is becoming frustrating.
Pointers are obsolete in Python; you can access any element of sequence types by indexing. If you want to have a more C-like behavior have a look at the at the cytypes module or at Cython.
How are pointers obsolete? How do I access mapped hardware registers at known addresses?
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

jahboater
Posts: 4769
Joined: Wed Feb 04, 2015 6:38 pm

Re: New to Python???

Fri Sep 30, 2016 2:43 pm

DavidS wrote:
gkreidl wrote:
DavidS wrote:How do you do pointers in Python? This is becoming frustrating.
Pointers are obsolete in Python; you can access any element of sequence types by indexing. If you want to have a more C-like behavior have a look at the at the cytypes module or at Cython.
How are pointers obsolete? How do I access mapped hardware registers at known addresses?
Probably by importing a library written in C

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: New to Python???

Fri Sep 30, 2016 5:11 pm

jahboater wrote:
DavidS wrote: How are pointers obsolete? How do I access mapped hardware registers at known addresses?
Probably by importing a library written in C
:(
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

jahboater
Posts: 4769
Joined: Wed Feb 04, 2015 6:38 pm

Re: New to Python???

Fri Sep 30, 2016 5:26 pm

Seriously, perhaps its worth finding the source of one of the public libraries to see how they access the GPIO registers.

evge128
Posts: 5
Joined: Mon Sep 26, 2016 7:47 pm

Re: New to Python???

Sat Oct 01, 2016 10:25 am

I recommend buying a couple of books on Python. I think Python has the largest bookshelf compared to other programming languages.

I think you should start with Python 3. Don't spend your time on the old version.

And checkout Jupyter. Jupyter makes playing with Python much more enjoyable: http://jupyter.org/

--------
Amie R. Flores
Certified Python Developer
http://www.java-tips.org
Last edited by evge128 on Sat Oct 29, 2016 2:40 pm, edited 1 time in total.

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

Re: New to Python???

Sat Oct 01, 2016 1:25 pm

DavidS wrote:How do I access mapped hardware registers at known addresses?
Explicit pointers are not a feature of the Python language so that capability would probably need to be provided by a library to do that. Perhaps take a look at PyGame, RPi.GPIO and other libraries which cater for such things.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: New to Python???

Sat Oct 01, 2016 2:28 pm

hippy wrote:
DavidS wrote:How do I access mapped hardware registers at known addresses?
Explicit pointers are not a feature of the Python language so that capability would probably need to be provided by a library to do that. Perhaps take a look at PyGame, RPi.GPIO and other libraries which cater for such things.
OK :( .

Thank you
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

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

Re: New to Python???

Sat Oct 01, 2016 2:32 pm

There are 10 types of people: those who understand binary and those who don't.

Return to “Python”