|
|
||||
|
||||
|
|
||||
|
||||
|
|
|
|
||||
|
||||
|
|
||||
|
||||
|
|
Learn Python | |
|
Python is a dynamic object-oriented programming language that can be used for many kinds of software development. It offers strong support for integration with other languages and tools, comes with extensive standard libraries, and can be learned in a few days. Many Python programmers report substantial productivity gains and feel the language encourages the development of higher quality, more maintainable code. (shamelessly stolen from the Python home page)
One interesting feature of Python is that it has an interactive console. If python is installed, just type "python" in a shell and start programming:
C:\Python25>python Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> i = 5 >>> print i 5 >>> What strikes most people just starting with Python is that whitespace means something. Rather than using brackets to enclose groups of code, groups of code at the same indent level are grouped. For example, let's declare a function:
>>> def double(x): ... y = x * x ... return y ... >>> double(2) 4 >>> To end the function declaration on the interactive console I just hit "enter" on a blank line. Note there's nothing to enclose the work being done in double() except the indent level. Python has object-oriented features. Without going into too much detail, let's declare a class and access some members:
>>> class Point: ... def __init__(self, x, y): ... self.x = x ... self.y = y ... >>> p = Point(1,2) >>> print p.x 1 >>> print p.y 2 >>> Compared to Java, there's a lot of syntax missing. For example, Python does not require that one declares member variables before he uses them. Also, Python also doesn't have the variety of access modifiers that there are in Java. Language Features Python doesn't skimp on features:
Python Documentation There are plenty of good sources of information on Python. I've found the following to be the most helpful:
| |