tags:

views:

2199

answers:

12

I currently program internet applications in php and mysql. I would like to broaden my horizons to new languages. What kind of things can be done with Python?

What kind of applications can be written on it other than internet apps? Can you write Windows/Linux programs in Python?

+13  A: 

For the same reason you would learn any language -- to experiment with and learn about new ways of programming. Python is powerful language, and makes use of idioms that are not possible in PHP like closures and callable parameters.

This advice applies to any language, especially those with styles that are foreign to you. Other good languages to learn, or at least play around with, are Haskell, Erlang, and Smalltalk.

John Millikin
+38  A: 

As for what tasks can be done:

  • Python is extremely fun to develop in.
  • Everything can be done with Python.
  • If something can't be done, you can create an extension for it.
  • Everything can not only be done, but it can be done fast. For example a program that takes you weeks in C++ might take you a day in Python.
  • Great for prototyping, and even for usage in a commercial setting.

As for language features:

  • Scripting language
  • Multi-paradigms (object oriented, imperative, functional)
  • Dynamic type system
  • Automatic memory management
  • Links to other dynamic languages
  • Embedding into other languages
  • Nice py2exe program that converts python scripts to executables for windows. Other platforms include it by default.
  • Strongly typed without static typing
  • Large standard library
  • Includes lists, dictionaries, sets, and much more as basic data types
  • Some implementations of python compile directly to machine code
  • It is actively being worked on
  • It has an antigravity module as noted by Jeremy Cantrell
  • ...

As for resources available:

  • Python is free to use
  • There are a ton of online resources and free tutorials
  • There are a ton of books on Python
  • There is a large community of developers available for help
Brian R. Bondy
But can it make toast? :)
Kev
from kitchen import Toastertoaster = Toaster()toaster.toast()
Adam J. Forster
might want to change pythong to python. I type that a lot too >.>
The.Anti.9
Thought I was the only one fixated with pythong
ayaz
don't forget the antigravity module :)
Jeremy Cantrell
Fixed pythong :)
Brian R. Bondy
Fixed not mentioning the antigravity module
Brian R. Bondy
So...you're a fan of Python I take it?
Anthony Potts
You forgot the most important. Python is fun!
Manuel Ferreria
The compiler also has rather clear error messages if something is wrong with your code. Much better than Java, for instance.
sventech
I don't know why but when he said "If something cant be done in python you can create an extension for it" made me laugh.
thyrgle
No, you can't do everything with Python, _fast_ bitmanipulations are a pain in the ass, c/c++ is better for this, and for some tasks its just too slow.
Quonux
@Quonux: Yes every language has its strengths and its languages, that's why there is not only 1 tag on stackoverflow.
Brian R. Bondy
+9  A: 

Why should you learn Python?

  • Because it is a modern, elegant, highest level OO language
  • Because it is highly expressive, i.e., you will earn higher productivity
  • Because it comes with "batteries included" i.e. libraries for whatever you want
  • Because it is well documented and has a well-established community
  • Because it is simple to learn (and easy to read!) if you already know another OO language
  • Because it is relatively portable (that is, portable until you use system-specific features)
  • Because it is free and already installed on any modern Linux distribution (and also on Mac OS X and *BSD, I guess)

As for what can be done in Python: everything except extremely low-level things (i.e. kernels, drivers, programming a microcontroller). Also, you should not use Python directly for number crunching (it is far too slow for that), but you can wrap C or C++ number crunching libraries with Python modules (and it has already been done, the most notable examples being Numpy and Scipy).

Federico Ramponi
+8  A: 

For the same reason you would learn any language. "If the only tool you have is a hammer, every problem looks like a nail"

Guido
A: 

It is possible to write portable desktop applications in Python. I've played a little with wxPython and it seems very nice (it has a native look-and-feel), but there are others you can try.

You already mentioned web programming, for which there are also working frameworks (Django, TurboGears).

rslite
+1  A: 

I don't have enough reputation on this user to comment, but in reply to Guido Garcia For the same reason you would learn any language. "If the only tool you have is a hammer, every problem looks like a nail"
True, but sometimes it's better to use a smaller hammer for smaller nails and a bigger hammer for a spike.

Tom
He meant exactly that: you learn new languages to have a varied toolbox and not be reduced to shoehorn everything to the same treatment.
Adriano Varoli Piazza
+1  A: 

Can you write Windows/Linux programs in Python?

Yes you surely can write almost anything in python ( both linux and windows ). Right from web servers to web applications, from applets to programs, even drivers. Depends how deep you want to drill.

Viky
plz, never write a driver in python, its just too slow to sit directly in the kernel...
Quonux
+2  A: 

Python is a good step language, it is very simple but powerful at the same time, that allows you to move into it as quickly as you need. It also comes with "Batteries Included" which means that a whole lots of things can be done straight after installation, from text file processing to web servers. Also it is a great toolbox language, for the same reason. The current version is 2.6 but the plan is to move to 3.0 in the next couple of months.

If you are going to learn python a good book is Learning Python is a very good introduction to python. It covers 2.6 and what was known of 3.0 at the time of publishing.

Andrew Cox
Learning Python now covers 2.6 and what was known of 3.0 at the time of writing, so I think it's the most up to date learning material.
Bastien Léonard
Thanks, I updated to reflect that.
Andrew Cox
+5  A: 

It makes programming fun!

monkut
+1  A: 
  • Because you can do far more things than PHP, for example cross platform desktop applications.
  • Because it is easy to learn and fun to code with.
  • Because it's a de-facto standard which ranks 6 in the TIOBE Index.
  • Because it is fast compared to some other scripting language
Mapad
+4  A: 

This essay discusses someone's experiences first learning Python. It does a fairly good job of conveying the strengths of the language.

ConcernedOfTunbridgeWells
A: 

It's very intuitive writing code in Python. I went the other way learning PHP after Python and it felt very weird, with funny function names and no name spacing.

googletorp