Python Language

Python is an ObjectOriented 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 http://www.python.org and the Python Wiki http://www.python.org/cgi-bin/moinmoin as well as source code and binaries for UNIX, Macintosh, Win95/NT, DOS, etc.


See also:


Python Web Frameworks
Python Books


Interfaces for Python extensions in CeeLanguage or CeePlusPlus


Interfaces for Python extensions in R (ArrLanguage)


Wikis about Python:


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:


Other applications that use Python:


TestingFrameworks:


Python Patterns


Python Implementations:


RefactoringBrowser:


Python advocates:


Useful Python Libraries:


Python comparisons:


Python's key features:


PeterNorvig on PythonForLispProgrammers: 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 has built-in ComplexNumbers. ComplexNumbersAreYourFriend.

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 (LispLanguage, PerlLanguage, ForthLanguage, SmalltalkLanguage - Perl's the worst offender). It has a very pragmatic feel. Lisp, SchemeLanguage, 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. -- AaronKristerJohnson?


(Moved from ObjectsAreDictionaries)

PythonLanguage 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 LawOfOrthogonality??

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)
CeeSharp:
 var myDict = new Dictionary<string, int> { { "a", 1 }, { "b", 2 }, { "c", 3 } };
 int value = someDefault;
 myDict.TryGetValue(someKey, out value);
 Console.WriteLine(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 LispLanguage or SchemeLanguage, 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?

-- AdamVandenberg

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 PythonLanguage 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 CeePlusPlus.

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 CeePlusPlus. 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 CeePlusPlus 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 EverythingIsaClass? was a very common paradigm in CeePlusPlus. Recently, it's come under fire by folks like HerbSutter, though, so it appears that CeePlusPlus 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.
CategoryPython CategoryProgrammingLanguage

EditText of this page (last edited January 2, 2014) or FindPage with title or text search

Meatball