Python Language

Python is an Object Oriented language that does all the things that you can do with Perl or TCL - only better, since it was designed from the ground up as an OO language. Lots of Python documentation is available at www.python.org and the Python Wiki www.python.org as well as source code and binaries for UNIX, Macintosh, Win95/NT, DOS, etc.


See also:

Python Problems - negative comments go here

Boa Constructor - RAD (gui builder) ide and Zope front end

Python Ide - They are springing out all over

Java Script Object Notation(JSON) (data interchange format)


Python Web Frameworks

Web2Py

Zope Application Server (Zope) - Application server in python


Python Books


Interfaces for Python extensions in Cee Language or Cee Plus Plus


Interfaces for Python extensions in R (Arr Language)

Arr Py (Rpy)


Wikis about Python:

The official Python Info wiki at wiki.python.org .

A German Language wiki about Python: mobbing-gegner.de


Wikis written in Python:


PEAK - PythonEnterpriseApplicationKit

I heard that it is an exciting development that is evolving, with proponents claiming superiority to J2EE.

What can it do already, at Jun05? Any good introductory reading on why people should keep an eye on it? -- dl


Games that use Python:

Blade of Darkness (several megabytes of Python scripts)

The Backyard Sports series, from Humongous

Uru: Ages Beyond Myst


Other applications that use Python:

GNU Mailman (mailing list software)

Pediatek (pediatek.com )


Unittest.py, an xUnit for python, is part of the standard library. (Python Unit)

Doc Test: testing-from-the-doc-string written by Tim Peters

py.test: Pythonic Testing Framework (codespeak.net )


Python Patterns


Python Implementations:

CPython: the canonical, reference implementation

Java Python: Jython (formerly JPython), implemented in Java Language. Emits Java Byte Code and integrates seamlessly with Java code

Stackless Python: supports continuation, coroutines, and microthread

Palm Python: python on PalmOS devices

Py Py: a self-hosting implementation of Python

Iron Python: Python implemented on top of the Common Language Runtime, for seamless integration with the rest of Dot Net


Bicycle Repair Man: Python Refactoring Browser (apparently stalled; no activity since 2004)


Python advocates:

Computer Programming For Everybody(Can End Users Script) : problems that Python tries to address.


Useful Python Libraries:


Python comparisons:

Python and Java Language side by side at: www.ferg.org

----

Python's key features:

Python is an excellent language for learning object orientation.

Python's Big Idea is that almost everything is a writable dictionary: dictionaries, classes, objects, stack frames, modules, etc. It's a very elegant and flexible idea.

And that you can make a reference to almost anything and pass that around. You have first-class modules, objects, methods, functions, etc.

Name Spaces too. Never forget about namespaces in Python.

Oddly enough, I thought Python's Big Idea was that everything is a sequence

Python has a Big Idea for everyone as the above 3 points would seem to indicate "Our chief weapon is surprise! Surprise and fear...fear and surprise... Our two weapons are..." -- Monty Python

And a fanatical devotion to the BDFL...

Perhaps it's more than there are no Big Ideas in Python, it's just a collection of well-thought-out features.

Who was it that said "Python gets all of its compromises exactly right."?

I think Python supports [Multi Paradigm Programming] well -- Martin Pool

Its other great strength is its scalability; -- Steve Freeman

It also does excellent support for all things Microsoft, and it's a nice way to lead VB folk out of the wilderness. -- Peter Merel

Completely open source.

Large set of standard/nonstandard libraries.

Enjoys almost-Smalltalk-like plasticity, with typeless variables, late-late binding and reflection.

Normally doesn't look like line noise run through an obfuscation filter [Though Obfuscated Python and Wy Py show how even Python can be made to look horrid]

Generators In Python, which support simple form of continuation. You'll be really amazed at how it can make complex stuff simple and elegant. -- June Kim

List Comprehensions from Haskell Language - see a quicksort implementation in Python Sample.

Duck Typing: you don't need a massive, static inheritance diagram. If an object implements the methods that, say, a file does, you can pass it to anything that expects a file, and it just works. (If you really want to live dangerously, you can even add the methods after instantiation, pass it like a file, and pull them back off the object when you're done. Dont Try This At Home.)

Insight: code will be read more often than being written: optimize for readability

Last but not Least: It has a cool name :-P (It's named after Monty Python, not the snake -- Wayne Werner)


Peter Norvig on Python For Lisp Programmers: Basically, Python can be seen as a dialect of Lisp with "traditional syntax."

Incorrect. No conditionals in lambda. And you can't use returns either. Or use lambdas as generators.

Actually conditional expressions have been added to Python 2.5, they look like this:

test_temp = lambda t:
"Above freezing" if t > 32 else ("Below freezing" if t < 32 else "At freezing")

Using lambdas with generators can be done by using functions from itertools (e.g. imap, izip)

Ah, but y = lambda x: foo is just syntactic sugar for

def y(x):

return foo

This is because the definition of a nested function will be re-evaluated (or at least appear to be) whenever its outer function is called. So Python does have "proper" higher-order functions, but without a nice syntax for anything more complicated than returning an expression.


Python is the best language I've tried for day-to-day quick programming. I've used it to manipulate text files, pipe formatting algorithms through a text editor, write music scripts, etc. I have to say I'm a believer in easy-to-use syntax that doesn't make you work hard and jump through hoops (Lisp Language, Perl Language, Forth Language, Smalltalk Language - Perl's the worst offender). It has a very pragmatic feel. Lisp, Scheme Language, etc. can can claim to be beautiful; Python is beautiful, easy-to-use, and powerful and practical for real-world apps. It even has support for a limited functional style for the pure academic type programmers out there. And recursion and iteration are equally supported, although performance is better for iteration, I think. -- Aaron Krister Johnson


Python Language implements objects as dictionaries, and "new-style" classes as objects.

IMO Python failed to capitalize on the similarities early on, and now seems to have created two different structures for things that are only slightly different from each other rather than consolidate, unnecessarily complicating the language. In general Python designers went structure-happy with dictionaries, tuples, lists, etc. that are only slightly different from each other. Perhaps it was done for speed, but it certainly complicates the language syntax. A violation of the Law Of Orthogonality?

Whilst I agree that Python is increasingly in danger of becoming unnecessarily complex, I think you're wrong about the structures. The variety of built-in structures with easy ways of expressing literals is one of the key strengths of Python. Python dictionaries and lists enable one to clearly express one's intention using literals. And the tuples exist to provide an immutable sequence for things like hashing.

I suppose we would have to compare and contrast some examples.

Python:

myDict = {"a":
1, "b": 2, "c": 3}

print myDict.get(someKey, someDefault)

var myDict = new Dictionary<string, int> { { "a", 1 }, { "b", 2 }, { "c", 3 } }; int value = someDefault; myDict.Try''''''Get''''''Value(someKey, out value); Console.Write''''''Line(value);

The paragraph below related to the old C#, I took the liberty of updating it to fairly idiomatic modern C#. It's worth noting that the initializer syntax used is general to all types, not specialized for dictionaries, and the new code is type safe where the old was not. Not an Object in sight.

One of these encourages the use of dictionaries more than the other, especially for things like lookup tables vs. switch statements. Looking through many introductions to C#, I see switch statements for stuff that I'd just hash in Python.

The other comparison would be between Python and a language with regular/minimal syntax, like Lisp Language or Scheme Language, I suppose.

As far as having lots of similar built-in structures, dicts are different from lists, of course. That there are immutable tuples and mutable lists that are otherwise similar is perhaps a wart. You can hash on tuples but not lists; I suppose if Python were being designed right now, mutability of objects might be handled differently.

Outside of dict, list, and tuple, what other built-in data structures are of note?

Well, objects (the base type of new-style classes) are interesting, as are generators (although they're not as general-purpose as the "big three" you list). Naturally, most code uses modules, methods, and functions; they're first-class types in Python just like integers and tuples.

It's a good idea to look over the methods of even the simplest types from time to time, because they have interesting properties that you might not know about otherwise.


I tore up some of my classes and made functions out of them. What's happening?? Seems I have learned enough of Python Language and can write code where I don't have to hide complexity. If I can see a function in half a page, I don't have to make a class and then call .doSomething(), like in Cee Plus Plus.

I'm trying to make sense of this. Freestanding functions are not a feature specific to Python - there's no reason you can't write them in Cee Plus Plus. In fact, Stroustrup rants against the "make everything a class" attitude of some coders.

I believe the point was that something that would take several pages in Cee Plus Plus can be done in half a page in python. Several pages of code requires some further organization; half a page can be understood on its own terms.

While free functions have always been perfectly acceptable in Python, until recently Everything Isa Class was a very common paradigm in Cee Plus Plus. Recently, it's come under fire by folks like Herb Sutter, though, so it appears that Cee Plus Plus is moving in this direction as well.

Variable names are becoming shorter. Is it me or Python influence?

I think it is the old C influence reasserting itself - those short, vowel-stripped variable names are something that people like to complain about in the common C libraries.


See original on c2.com