Jaseman's Python Lessons


61 posts   Page 2 of 3   1, 2, 3
by Jaseman » Mon Feb 06, 2012 10:32 am
A quick note for any Windows 64-bit users:

Don't install the 64-bit version of Python - it's not compatible with pygame.  The 32-bit python works just fine on 64-bit Windows.
Posts: 302
Joined: Tue Jan 10, 2012 12:59 pm
by Himalaya » Mon Feb 06, 2012 11:48 pm
Hi, I am having a bit of trouble with part one of the tutorial, step 13.

This is the error I am getting:


File "demo.py", line 23
PasteRect(topx, topy, width, height, color):
^
SyntaxError: invalid syntax



Any help is appreciated.
Posts: 2
Joined: Mon Feb 06, 2012 11:41 pm
by gimliflea » Tue Feb 07, 2012 12:12 am
I think you need a def at the start of that line. Either that or no colon at the end.
Posts: 76
Joined: Fri Nov 18, 2011 4:14 pm
by Himalaya » Tue Feb 07, 2012 12:32 am
@gimliflea

Thanks, that was indeed the issue (needed 'def' at the start of the line).
Posts: 2
Joined: Mon Feb 06, 2012 11:41 pm
by Jaseman » Wed Feb 08, 2012 9:06 am
Well spotted there.  Great to see that you are helping each other out.

I'm having a little break from programming for a few days.  My mountains.py program is coming along.  I'm planning to have a runway in front of the mountains and a 747 whizzing along it.  I'm interested in playing around with graphics and random numbers.  I think you could get some interesting textures by putting down random dots, short lines or small ellipses in close colours.   I would like to draw a tree, some shrubberly, and try to draw some sand/dirt or grass, using texture to add depth to those solid polygons.

I thought about starting a contest....

Who can make the coolest python demo in less than 1000 lines of code?

There's probably enough in lessons 1-6 to give you enough to put something together.

Let's see what you can come up with.  Give me a shout if you need some help.  I'll do my best!
Posts: 302
Joined: Tue Jan 10, 2012 12:59 pm
by gimliflea » Thu Feb 09, 2012 10:40 am
I am finding this  site http://cs.simpson.edu/cmsc150/index.php a useful resource for learning python.
Posts: 76
Joined: Fri Nov 18, 2011 4:14 pm
by gimliflea » Tue Feb 14, 2012 1:18 pm
Another python learning website http://www.learnpython.org/

This one is very basic level but has the advantage that it all works in the browser so there are no downloads, setting up, or compatibility issues.

If you are interested in trying python this is the minimum hassle way I have found.
Posts: 76
Joined: Fri Nov 18, 2011 4:14 pm
by JBurd » Tue Feb 14, 2012 3:11 pm
Thanks - this got me off to a good start - nice progression through the lessons
Posts: 2
Joined: Sat Feb 04, 2012 9:27 am
by Jaseman » Tue Feb 14, 2012 6:35 pm
I'm planning to do a whole bunch of short Python examples.  I'm waiting for the Ras'Pi to become available to be honest, before going too far with the tutorials.

I know there will be an official Raspberry manual coming out - eventually, and also there is the wiki.  I might do an unofficial manual of my own, at least to tide people over until the proper one comes along.

If you are interested in virtual machines like Oracle Virtual Box, VMWare Player or MS Virtual PC, it might be worth putting together a virtual machine of Linux Fedora.  According to the FAQ, that is going to be the standard educational distribution of linux that the Raspberry will use.  Of course there will be other distros, ArchLinux and Debian are mentioned, but you can expect there will be a multitude on offer.

I'll be focusing on the officially supported version and any tutorials I do will be based upon that.  I'm planning to buy one of the Fedora SD cards from the shop when they become available.  Although I know I could download/flash/build one myself, I'm guessing that most of the beginners will opt to buy one, so I want to make sure I'm seeing exactly the same thing that they are getting.  Not that there is anything wrong with building your own of choosing a different distro.  If you are up for that, then go for it.  It just doesn't interest me to try and support such a varied range of platforms.

You should be aware that all the different flavours of linux are very similar, so if you've used one, you will easily migrate to another.

I happen to think there is TOO much choice.  It just confuses the hell out of people, and you are always left wondering if you made the wrong choice.
Posts: 302
Joined: Tue Jan 10, 2012 12:59 pm
by JBurd » Wed Feb 15, 2012 3:59 pm
I think you make a good point about choice. For those of us returning to playing around with coding (used to do it a lot in the 80's) not only the choice but also the complexity are potentially off-putting. When I first heard out RPi I was kind of hoping it would be back to the days of POKEing registers / video RAM and seeing the effects just like early days of the ZX Spectrum / CBM64. Instead we have something massively complex and powerful. Having reflected on it, I'm sure the team have made the right choice - it needs to be this capable to remain relevant and inspire the younger audience rather than some retro-computing nostalgia trip - but I can't help feeling that unless it gets down to the basics of bit level something will be missed. Back in the day when we were playing around with the multitude of 8-bit micros, they were the forefront of home computing, combined with the lack of internet, every bit of technical info or trickery gleaned through books and magazines was gold dust (remember the Z80 hidden instructions?) but I suspect for my 8 year old son, would hold no attraction now. It will be a fascinating  to see how the educationalists and the computing experts drawn to this project combine and rise to the challenge and find out if the mass interest in computing of the 80's can be re-kindled (no pun intended) or has the technology moved on so far that it is now effectively confined to the realms of higher education (consider a medicinal garden vs pharmacology)?

Anyway as a returnee I would like to thank you and all the other contributors for your efforts and patience - just hope that after all this time the step up is not too high.
Posts: 2
Joined: Sat Feb 04, 2012 9:27 am
by Jaseman » Thu Feb 16, 2012 9:34 pm
Don't worry.  It's actually not as complex as you might imagine.  The problem is on the forums, everyone has an opinion, and there's going to be a lot of disagreements and a lot of highly technical talk which will scare people - especially the beginners.

Already so much has been said, and the thing isn't even available yet!  It might actually be beneficial for the beginners to step back and wait until things settle down.  Let all this chatter wash over you for now.

Everyone is at different levels, and there's no use trying to understand what the guru's are on about.  I don't understand half of what they are talking about.  Much of it is irrelevant to the average person.  I'm not going to be building my own hardware, connecting things to the GPIO, soldering or any of that stuff - at least for a good while.  Get comfortable with the software side of things first.  You won't even have to worry about Linux.  If you've used Windows, you're going to see very similar things - the start menu, and the desktop.  Let the foundation get it's act together - it's going to be a few months, but they are working feverishly to get things up and running.  Wait for the beginners guide's to start appearing.  We can't really begin writing those properly, when we don't even own the hardware yet.

Everyone has got a little bit too eager in anticipation of the launch, and I'm seeing some people even getting hot-headed over it.  What you should do is find something else to occupy your time, and take your mind off the Raspberry Pi.  Chill out, keep an eye on progress of course, and wait until it is ready and any minor bugs or glitches will have been ironed out by those nerdy know-it-alls.
Posts: 302
Joined: Tue Jan 10, 2012 12:59 pm
by Jaseman » Wed Mar 07, 2012 10:02 pm
A little update, as I haven't posted anything for a while:

I'm still alive and keeping an eye on the launch.  I personally didn't bother to get up at 6am.  The demand for the R'pi is now in the millions by my estimation, and it's going to take a good while to meet a demand like that.  Which means that for the vast majority of us, we will have to keep waiting and being like Fonzie.

My advice would be not to even attempt to buy one yet.  Hopefully things will start to run smoother in time, and the whole buying experience will be a more pleasant one.  Save yourself the torment - worrying over estimated delivery dates and such.  I'll be looking to read things on the forums like 'I placed my order, and it all went through like a dream.'
Posts: 302
Joined: Tue Jan 10, 2012 12:59 pm
by antiloquax » Tue Mar 13, 2012 7:52 am
Hi Jaseman,

I hadn't seen this thread before today - I looked after Liam Fraser mentioned it in his video. I will be downloading your lessons and having a go!

I'm a teacher and I have been doing some Python with my Y9 classes (in English lessons!).

If you are interested, here are the blogs I have been working on:

100mudcats (only about 3 posts on coding - aims to be VERY simple!)

TeamPython (Coding and stuff on RPi / Linux).
Posts: 406
Joined: Sun Nov 20, 2011 11:37 am
by Jaseman » Tue Mar 13, 2012 1:26 pm
I shall certainly take a look at those.  My tutorials may be a little rough around the edges, and things might not have been done in the most efficient way, however I think a beginner should find it fairly easy to follow, and hopefully start to understand some of the principles of programming.  Maybe we can all get together (Liam and whoever may be interested) in some sort of collaborative Python learning project.

I decided to halt producing any more tutorials until I can get my hands on a Raspberry Pi, because I want to write my programs to work well within the capabilities of the hardware.  I noticed that the experience can vary wildly depending on what sort of processor you have and if you are running inside a virtual machine or not.
Posts: 302
Joined: Tue Jan 10, 2012 12:59 pm
by meltwater » Tue Mar 13, 2012 1:33 pm
I think a series for the community magazine would be welcomed, if you are interested in the future.

Would it be possible to provide a zip file with them all to date (it'll make it easier to follow offline for some).  As always, excellent work!
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 993
Joined: Tue Oct 18, 2011 11:38 am
by antiloquax » Tue Mar 13, 2012 3:21 pm
Jaseman said:


Maybe we can all get together (Liam and whoever may be interested) in some sort of collaborative Python learning project.


That sounds like a great idea. It would be good to have some sort of Python Learning "hub" for the RPi, so that people can find tutorials etc easily.  Also, we could have an overview of what people were working on.

I loved the "timewarp" program, by the way, I haven't done much with Pygame yet! I'm still playing around with PyShooter from Liam's videos.

mark
Posts: 406
Joined: Sun Nov 20, 2011 11:37 am
by Jaseman » Wed Mar 14, 2012 9:39 am
There's a strong interest in having type-in programs (http://en.wikipedia.org/wiki/T.....in_program) just like we had in the 80's with magazines like 'Sinclair Programs'.

I will submit some to the community magazine, if they are happy to include it.  I'm not even sure who 'they' are at the moment.

I have a feeling that there will be several raspberry pi community groups and publications springing up.  There will be an official manual, and probably a few unofficial ones too.  I may put one together myself.  I don't really want to repeat the work of someone else, but my personal experience is that often with computer literature, there is a tendancy to over-complicate things.  The person writing them is usually an expert and it's hard for them to see it from a beginners point of view.  You must never assume that the reader knows what you are talking about.  Some things you might take for granted, others don't know about yet - No point to go on about strings and variables, if the reader has absoultely no concept of what a string is.
Posts: 302
Joined: Tue Jan 10, 2012 12:59 pm
by Jaseman » Wed Mar 14, 2012 9:55 am
antiloquax said:


Hi Jaseman,

I hadn't seen this thread before today - I looked after Liam Fraser mentioned it in his video. I will be downloading your lessons and having a go!

I'm a teacher and I have been doing some Python with my Y9 classes (in English lessons!).

If you are interested, here are the blogs I have been working on:

100mudcats (only about 3 posts on coding - aims to be VERY simple!)

TeamPython (Coding and stuff on RPi / Linux).



I particularly like 'Program To Annoy People Who Work In PC Shops'.  They deserve to be annoyed as usually whenever a customer is waiting for assistance, they all tend to rush off out the back door to avoid helping you.  I know they are on minimum wage, but it's still a bad work ethic.
Posts: 302
Joined: Tue Jan 10, 2012 12:59 pm
by Jaseman » Wed Mar 14, 2012 10:05 am
meltwater said:


I think a series for the community magazine would be welcomed, if you are interested in the future.

Would it be possible to provide a zip file with them all to date (it'll make it easier to follow offline for some).  As always, excellent work!



https://skydrive.live.com/redir.aspx?cid=f41ca64cc38a2ec5&resid=F41CA64CC38A2EC5!333&parid=F41CA64CC38A2EC5!182

Here's a zip containing all my tutorials to date.  It's a 7.5Mb download.
Posts: 302
Joined: Tue Jan 10, 2012 12:59 pm
by meltwater » Wed Mar 14, 2012 10:34 am
Jaseman said:


I will submit some to the community magazine, if they are happy to include it.  I'm not even sure who 'they' are at the moment.

I have a feeling that there will be several raspberry pi community groups and publications springing up.  There will be an official manual, and probably a few unofficial ones too.  I may put one together myself.  I don't really want to repeat the work of someone else, but my personal experience is that often with computer literature, there is a tendancy to over-complicate things.  The person writing them is usually an expert and it's hard for them to see it from a beginners point of view.  You must never assume that the reader knows what you are talking about.  Some things you might take for granted, others don't know about yet – No point to go on about strings and variables, if the reader has absoultely no concept of what a string is.


They are two groups at the moment (I'm not taking sides…although would make sense to join), however I'm keen for any magazine to be produced.

The details are in the wiki, http://elinux.org/RPi_Community_Magazine

I agree with you about documentation, it is very hard to write quality stuff for beginners.

Also I know we may well suffer with the problem that there will be 101 beginners guides etc, so it will be difficult to avoid duplicating work and also the risk for gems to get lost in the noise.

Perhaps the foundation could hold a few competitions for "best article about…xyz".  That way people can find the most useful information out-there.  Still, it is all a little difficult without something real to work with, a lot is just re-written from other articles.

The thread about "jetpack" mentioned about a type in program (although obviously there are legal things with that).  Anyway, diverted your topic enough.

***Thanks for the ZIP!
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 993
Joined: Tue Oct 18, 2011 11:38 am
by antiloquax » Wed Mar 14, 2012 1:32 pm
Jaseman said:


I particularly like "Program To Annoy People Who Work In PC Shops."


Thanks for having a look!
Posts: 406
Joined: Sun Nov 20, 2011 11:37 am
by meltwater » Wed Mar 14, 2012 2:24 pm
antiloquax said:


Jaseman said:


I particularly like "Program To Annoy People Who Work In PC Shops."


Thanks for having a look!


antiloquax said:


If you are interested, here are the blogs I have been working on:

100mudcats (only about 3 posts on coding – aims to be VERY simple!)

TeamPython (Coding and stuff on RPi / Linux).


I seem to say this a lot, but please add this to the wiki (community pages) that way others can find these great blogs! (I'm adding to my RSS reader now if I can)

Feed URL: http://100mudcats.wordpress.co.....p-rss2.php
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 993
Joined: Tue Oct 18, 2011 11:38 am
by rbn » Thu Mar 15, 2012 12:11 pm
Hi Jason

Which distro do you use for Python? I was on Python 2.5 in the debian distro that Liam used, but it doesn't support import argparse. I added Python 3.1 but this still doesn't work. Any help on what I need to get it going appreciated.

Great tutorial enjoyed completing all the other lessons.

Robin
Posts: 60
Joined: Tue Dec 27, 2011 8:32 pm
by antiloquax » Thu Mar 15, 2012 6:35 pm
meltwater said:


I seem to say this a lot, but please add this to the wiki (community pages) that way others can find these great blogs! (I"m adding to my RSS reader now if I can)

Feed URL: http://100mudcats.wordpress.co.....p-rss2.php



Thanks meltwater - I have added my programming club and a link to TeamPython to the RPI Hub education page!
Posts: 406
Joined: Sun Nov 20, 2011 11:37 am
by Jim Manley » Thu Mar 15, 2012 9:13 pm
Jaseman said:


Perhaps the foundation could hold a few competitions for "best article about…xyz".  That way people can find the most useful information out-there.


There have been hints that this blog/forum software is going to be upgraded to something better within the coming month, or so, and I hope that means adding a "Like" or "+1" kind of feature, where readers can rate the benefit of various posts, attachments, links, etc.  That would help separate the tastiest wheat grain from the chaff.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!
User avatar
Posts: 1356
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, USA