Revision 5 as of 2002-10-23 03:33:46

Clear message

Moving to Python from other Programming Languages

If you are already a programmer, Python could be the easiest to learn of all the languages you have encountered. It is pretty typical to learn the Python language while you are writing your first non-trival Python program! In other words, feel free to skip "Hello World" and move right to file administration, GUI programming, and exotic numerical analysis! I am exaggerating, I admit! :) But you will definately be much farther with Python during your first 3 days than you would be with any other language.

Here is an account of a programmer coming to Python and being extremely productive far sooner than he expected to be.

* [http://www.linuxjournal.com/article.php?sid=3882 Eric S. Raymond 'Why Python?']

Significant Whitespace

The less said, the better. Python uses whitespace to signify end-of-line and code blocks. This will annoy you! But you will get used to it, as did thousands of programmers before you. You might even grow to like it.

comp.lang.python

Probably your most valuable Python resource, right after python.org. Spot Python luminaries in their native habitat! Don't be surprised to have your questions answered by the original programmer or the author of the book open on your desk! The best thing about comp.lang.python is how "newbie-friendly" the mail group is. You can ask any question and never get a "RTFM" thrown back at you.

Tips for "Thinking in Python"

(The phrase Thinking in Python was borrowed from the Bruce Eckel book of the same name. It is currently an online book, available for reading for free-as-in beer! ["http://www.mindview.net/Books/TIPython" Mindview Inc. Thinking in Python] This book is not meant for beginners to Python, however. It is the Python equivilant of Bruce Eckel's popular Thinking in C++ and Thinking in Java)

The following was taken from a post in comp.lang.python from Mel Wilson, which I thought well summarized good Python programming style for people coming from other languages. I also added some things I would have appreciated knowing during my first 3 days with Python.

Python indexes and slices for a six-element list.
Indexes enumerate the elements, slices enumerate the spaces between the elements.

Index from rear:    -6  -5  -4  -3  -2  -1      a=[0,1,2,3,4,5]    a[1:]==[1,2,3,4,5]
Index from front:    0   1   2   3   4   5      len(a)==6          a[:5]==[0,1,2,3,4]
                   +---+---+---+---+---+---+    a[0]==0            a[:-2]==[0,1,2,3]
                   | a | b | c | d | e | f |    a[5]==5            a[1:2]==[1]
                   +---+---+---+---+---+---+    a[-1]==5           a[1:-1]==[1,2,3,4]
Slice from front:  :   1   2   3   4   5   :    a[-2]==4
Slice from rear:   :  -5  -4  -3  -2  -1   :
                                                b=a[:]
                                                b==[0,1,2,3,4,5] (shallow copy of a)

Unable to edit the page? See the FrontPage for instructions.