Easy way to start programming with python

Background I'm trying to learn how to program a bit, and python seems like a good choice for my purpose. I have no ambition to be a serious programmer. I already know html, css, javascript snippets (basically how to cut and paste without understanding what I'm doing). The last time I actually "studied programming" was about ten years ago, in high school, using Pascal. We have not reached this far. What we did was what, in my opinion, programmers call a "medium" that made some sense. In the "code" (program) there was a place somewhere, and then the "compile" button, then (if it worked) the "run" button.

Python Environment (is that the right word?) Now I'm trying to get a setting where I can put an hour or two when I have time, but was completely unable to set up. Any tutorials or manuals I tried to use seem to come into things like Shell, IDE, Interactive Shell, terminal, command line interface.

My failure so far. For example, I just tried following the instructions for setting up diveintopython. I am using mac. This tells me that for the first few chapters, I can buy with the python command line version if I like it (I don't), or I can download a graphical interactive shell that will also be relevant. I get to homepages.cwi.nl/~jack/macpython/download.html here, where it tells me that for osx10.3 (I'm at 10.5) it is already installed. I just need an “IDE,” “Package Manager,” and the waste module that they depend on. ”They seem important (the waste module sounds pretty dubious) because they sound like I can click on something and open it, in order to enter the code from the textbook in some way that resembles the way I did it ten years ago in Pascal, maybe, I hope.

In any case, since this seems to be the latest version, I install this. I click on PythonIDE and nothing happens. Is it because I'm using the osx 10.3 package?

Then I realized that I seem to have Macpython2.5 installed. Not sure if this happened to the machine, or if I installed it at some point (this is not my first unsuccessful attempt), which for some reason corresponds to mac osx 10.5 in some way. But, since the instructions on the site above point to 2.3, there is no PythonIDE dispatcher or package.

Is there an easier way to do this? I know that I wrote the sounds comical, but I'm really stuck, and as you can see, I don’t even know what to ask. I'm not even sure what “install python” means. I am not sure where I am writing the program. I am not sure how I run it. I am sure that you are not compiling python the way we compiled Pascal.

What questions should I ask?

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

** Sidestory * Once I tried to start learning programming with php and made some basic progress. This took some time, but in the end I realized that the php program runs inside the html file, which should (unlike regular html files) run through the Apache server. Where I am writing a program is a text file. When I "compile and run", the program is in the browser / web server. I thought it was difficult, but I understood everything and after half an hour I worked through a php-tutorial.

+4
source share
9 answers

Many great “Python lessons for non-programmers” are listed here !

+3
source

I recommend biting a bullet and using the command line version to get started. Later you will write scripts and you will need a good editor, but not necessarily the python IDE.

For learning, I found a 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 already have python installed, so installation is not required. To check, just type "python -version" at the command prompt in the terminal.

+2
source

Start with the basics:

Python Installer 2.6.4

The Official Python Guide

How i did it.

+2
source

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

  • Python 3 for absolute beginners
  • Python 4th Edition Training
  • Python Pocket Reference (when you started coding basic materials and need a handy reference)
+1
source

If you are a true beginner; ALWAYS maintain an interactive shell (even if you write your code and tutorials in an editor) and make extensive use of help(whatever_you_need_help_with) and dir(whatever) .

For instance:

 >>> 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, ie words start with uppercase characters, all remaining cased characters have lowercase. >>> a.title() 'Foobar' 
+1
source

Since you are on OSX, you do not need to install anything to get started. Just open a terminal application and enter python . You will be taken directly to the Python shell (command line), where you can enter simple Python programs.

If you want to write longer, just do what you did with PHP - write them to a text file, save them, and then simply type python myprogram.py in the shell. (Note that you must first exit the existing Python shell by pressing Ctrl-D).

As for books, Dive Into Python is a fantastic guide, but it is solidly aimed at people who already know how to program. There are many beginner guides for the link that Alex gives.

+1
source

I wrote "Building Skills in Programming" for people who are struggling, this can help.

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

+1
source

The easiest way to get started is with an online interpreter like Try Python or codepad .

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

There are many great python lessons you can run here .

0
source

Buy

Head first programming

This seems like a really neat book ^^

0
source

All Articles