views:

190

answers:

9

Background I'm trying to learn to program a little & python seems like a good choice for my purpose. I have no ambition of ever being a serious programmer.I already know bits and pieces of html, css, javascript (mostly how to cut & paste without understanding what I'm doing). The last time I actually "learned programming" was about ten years ago in, high school, using Pascal. We didn't get all that far. What we did have though was what I think programmers call "an environment" that made some sort of sense. There was someplace to type in the "code" (programs), then a button to "compile," then (if it worked) a button to "run."

A Python Environment (is this the right word at all?) Now I have been trying to get a set up where I can put in an hour or two whenever I have time but have utterly failed at setup. Any tutorials or guides that I have tried using seem to jump in with things like Shell, IDE, Interactive Shell, terminal, command line interface.

My Failure So Far For example, I just tried to follow diveintopython's setup instructions. I'm using a mac. It tells me that for the fist few chapters I can get buy with python's command line version if I am comfortable with that (I am not) or I can download graphical interactive shell which will also be up to date. I go to here homepages.cwi.nl/~jack/macpython/download.html where it tells me that for osx10.3 (I'm on 10.5) it's already installed. I just need the "IDE, "the Package Manager" and the waste module on which they depend." They sound important (waste module sounds kind of dubious) because they sound like maybe I can click on something and have it open up a place to type in the code from the tutorial in some way that resembles the way I did it ten years ago in Pascal. Maybe. I hope.

Anyway, since that seems to be the most recent version, I install that. I click on the PythonIDE & nothing happens. Is it because I'm using the osx 10.3 package?

I then figured out that I seem to have macpython2.5 installed. Not sure if this came with the machine or if I installed it at some point (this is not my first failed attempt) which for some reason I assume corresponds to mac osx 10.5 in some way. But, as the instructions on the site above suggest for 2.3, there isn't a PythonIDE or package manager.

Is there an easier way to do this? I know what I wrote sounds comical but I'm really stuck & as you can see, I don't even really know what to ask. I'm not even really sure what it means to "have python installed. " I'm not sure where I write the program. I'm not sure how I run it. I'm fairly sure that you don't compile python the way we compiled Pascal.

What questions should I be asking?

http://dl.dropbox.com/u/131615/screenshots/Snapshot%202010-01-12%2011-23-23.tiff

*Sidestory I once tried to start learning to program with php & made some basic progress. It took a while but I eventually figured out that a php program runs inside a html file that must (unlike normal html files) be run through an apache server. Where I write the program is a text file. Where I "compile & run" the program is in the browser/webserver. I thought that was complicated but I did figure it out and was working my way through php tutorial in about half an hour.

+3  A: 

I recommend biting the bullet and using the command line version to start with. Later you'll get onto writing scripts and you'll need a good editor, but not necessarily a python IDE.

For learning I found the "Python Tutorial" by Guido van Rossum, the author of python, to be a good starting point. ( http://docs.python.org/tutorial/ )

And since you're on OSX you probably have python already installed so no install needed. To check just type "python --version" into the command prompt in a terminal.

Michael Anderson
A: 

The easiest way to start will be an online interpreter like Try Python or codepad.

Type print "Hello world" after the >>> in the input field and press enter. Your first Python program should be done.

There are lots of excellent python tutorials out there, you could start here.

Peter Lang
thanks for the reply, IS using an interpreter like this different in any way from using the command line?
net
It is the same for the language basics. Once you need to work with resources or pass arguments, you will have to switch to command line though (see Michael Andersons answer and Greg Hewgills about Python already being installed on OS-X).
Peter Lang
+3  A: 

Lots of great "Python tutorials for non-programmers" are listed here!

Alex Martelli
Care to explain why this was downvoted?
Peter Lang
No idea, it's a great link.
Travis Bradshaw
+2  A: 

Start with the very basics:

Python 2.6.4 Installer

The Official Python Tutorial

That's how I did it.

sdornan
Mac OS X comes with Python installed, so for a beginner I'd skip the install part.
Greg Hewgill
A: 

Buy

Head First Programming

Seems like a really neat book ^^

Helper Method
+1  A: 

I was in the same boat, two books really helped me:

  • Python 3 for Absolute Beginners
  • Learning Python 4th Edition
  • Python Pocket Reference (for when you've started coding basic stuff and need a handy reference book)
Nimbuz
+1 for "Learning python" - I think that book should be used to teach programming 101 **everywhere**
Kimvais
+1  A: 

If you are a true beginner; ALWAYS keep the interactive shell handy (even if you write your code and tutorials in an editor) and use help(whatever_you_need_help_with)and dir(whatever) extensively.

For example;

>>> a = "foobar"
>>> dir(a)
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__',
 '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__',
 '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', 
'__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', 
'__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 
'expandtabs','find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace',
'istitle','isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex',
'rjust','rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 
'title','translate', 'upper', 'zfill']
>>> help(a.title)
Help on built-in function title:

title(...)
    S.title() -> string    

    Return a titlecased version of S, i.e. words start with uppercase
    characters, all remaining cased characters have lowercase.

>>> a.title()
'Foobar'
Kimvais
Honestly, I'm not entirely sure what the interactive shell is. Is this Terminal?
net
It's the thing you get when you type "python" in terminal. Or start "python (command line)" or "IDLE" from menu.
Kimvais
+1  A: 

Since you're on OSX, you don't actually need to install anything to get started. Simply open up the Terminal application, and type python. You'll go straight into the Python shell (command line) where you can type simple Python programs.

When you want to write longer ones, simply do as you did with PHP - write them in a text file, save them, then in the shell just type python myprogram.py. (Note that you'll have to quit the existing Python shell first, by pressing Ctrl-D).

As regards books, Dive Into Python is a fantastic guide but it's firmly aimed at people who already know how to program. There are plenty of beginners' guides at the link Alex gives.

Daniel Roseman
+1  A: 

I wrote Building Skills in Programming for folks who are struggling, it may help.

http://homepage.mac.com/s_lott/books/nonprogrammer.html

S.Lott