views:

395

answers:

8

I started learning Python through some books and online tutorials. I understand the basic syntax and operations, but I realize that the correct way to understand the language would be to actually do a project on it.

Now when i say a project, I mean something useful, maybe some web app. I started searching for web programming in python and landed on a couple of tutorials referencing a very complex code. most of it was based upon, i think, CGI programming.

now what i would really appreciate is if someone could provide certain guidelines on how a beginner like me can understand the various aspects of programming the web through python. because the things i am seeing are just confusing me. can anyone please help?

+4  A: 

If you want to create a powerful web application with Python, Django is the way to go. You can start with the documentation at http://docs.djangoproject.com/en/dev/ or the Django Book (I recommend the latter). It's a bit complicated to grasp as a beginner, but it's totally worth the hassle :)

Good Luck!

Gerald Senarclens de Grancy
i want to use python with the opensocial client for python. is it possible with the Django framework?
amit
I've never used OpenSocial, but it looks good: http://code.google.com/p/django-opensocial/
Gerald Senarclens de Grancy
its empty. no progress has been made. i think the normal python client for opensocial wont work with django?
amit
That's probably worth a new question since it isn't even mentioned in the above one. If you'll have it in the title, you'll most certainly get a competent answer. Like I said - I had never used OpenSocial. Sorry.
Gerald Senarclens de Grancy
+6  A: 

+1 for django, though the "django book" is a little simpler to understand (especially if you're just getting start with python): http://www.djangobook.com/en/2.0/

pklall
djangobook.com is a great resource, start there and create tiny personal apps for yourself
amoeba
+2  A: 

Start with the Django tutorial here http://docs.djangoproject.com/en/dev/intro/tutorial01/ and work your way to the end, then go back and read the rest of the Django documentation.

ken
+2  A: 

Google App Engine uses python and runs on Google's infrastructure: http://code.google.com/appengine/

They have many tutorials and examples that can help you get started.

Jake
+2  A: 

Start by writing really simple network application.

Try starting with a small program that listens on a port, and gives some status message when questioned. For example, when a web browser calls it, It would display the time and some facts about the system.

That would tech you the basics, and you'll find your route from there on.

EDIT:

Begin with Making a simple web server in Python. If you want to learn some theoretical background, try the legendary Beej's Guide to Network Programming. The examples are in C, but it'll get you through terms like socket, bind, port and listen.

If you're unhappy with the tutorial I have given above, Just Google "Python server" or "Python network tutorial" and you'll find lots of them.

Adam Matan
that is a great idea. do you have any links from where i can begin?
amit
Ye's, I'll update soon.
Adam Matan
A: 

There are many web frameworks for Python.

The most popular is Django, but don't believe the people here that it is "the only way" or similar. They simply haven't used any other.

Look around to see what you want, read the tutorials to see what makes sense to you. And if you can't make up your mind, then go for Django. :-)

Lennart Regebro
Django is fairly feature rich, but calling it "full stack" is overstating it a bit. People regularly discuss deploying contrib.admin independently of django.
ken
Django people themselves claim Django to be full stack, so I don't think it's overstating anything at all. Why contrib.admin would be relevant to this escapes me.
Lennart Regebro
+2  A: 

You can read substantial parts of "Python in a Nutshell" for free online -- though selective pages are being omitted at the publisher's request to induce you to buy the book -- and other only partly-overlapping parts of the second edition here. The chapters I'm pointing you to in both the first and second editions are about sockets and server-side network programming, the immediately previous ones cover network and web programming with a focus on the client sides, and following ones cover CGI and alternatives, HTML, XML, etc.

Not covered, due to the age of the books, is the best alternative to CGI, WSGI (can actually be deployed on top of CGI, but also very efficiently on Apache, nginx, Google App Engine, etc; and basically all modern Python web frameworks run well on top of WSGI -- there are also some highly modular "not quite frameworks" such as werkzeug that are totally WSGI-focused).

To deliver a working Python web app ASAP, Django is probably the best and definitely the most popular choice today; but the very aspects that make it such a high-productivity environment (the huge amount of things it does "hiddenly and magically" on your behalf) make it less useful for pure learning purposes than more modular, less abstract, less magical frameworks such as Paste, Pylons, Werkzeug, &c. It's very instructive to start on plain WSGI and add helpful components and middleware only gradually as you understand why they're better than doing it all yourself "by hand".

For more info on WSGI, see its own site which is rich with helpful links & docs.

Alex Martelli
that is what i was thinking while reading about django. my main concern with using a framework was the fact that i wasnt learning python per se. how to go about the task if i dont want to use a framework?
amit
You start with the WSGI site and the tutorials it links to, maybe some of the intermediate stuff (you don't need much), then you install the opensocial Python client and the app engine SDK: the client's samples use appengine, via WSGI and the extremely lightweight "non-framework" that comes with it (just a response and request objects from WebOb and the simplest URL-dispatching scheme you'll ever see) -- then you get an app engine free account and an app name and start developing your opensocial apps (and deploying them for free at any likely amount of traffic!-).
Alex Martelli
A: 

If you start with Appengine (Django, webapp, DIY with WebOb, Pylons -- whatever) then if you get an application written, no matter how stupid or trivial, you can deploy it and it'll keep working and you can share it with people. The whole deploy-and-keep-working task is largely unrelated to programming or Python, but it's also a lot of work. By skipping that you can focus on the programming and have the motivation of making real deployed applications.

ianb