views:

584

answers:

10

I'm attempting to teach myself Python as my first language. After reading through "Python for Dummies" I searched out a number of easy projects that I could attempt.

However, my main problem is not knowing a large enough breadth of modules and functions to use. I feel like I just don't know enough. Sure, I understand the basics of built-in types, functions, etc. But when I'm given a certain task, I just don't know where to start, and what modules to import.

I eventually want to get into web application programming and create Web 2.0 sites. I know this is very difficult, and that I have to master the basics first. I tried installing Django but I'm having trouble getting started with it. I tried to follow the instructions on the site, but they were too nebulous for me.

What I'm basically asking is what step should I take from here? As you can probably tell, I'm getting rather frustrated.

A: 

Get a book that walks you through building a demo application. The more recent the better. Stick with the specific version of the tools / language that they use in the book to minimize environmental issues.

Javid Jamae
+11  A: 

Well, I'm always finding modules that do things, sometimes things I've already done myself. I wouldn't worry too much about that. Learn the modules in the standard Python library and what they do, or just hunt through the list when you have a task you think should've already been solved.

Eventually, you'll gain facility with this an you can move on to trying to discover some of the other stuff other people have done.

As commenter Andrew pointed out, another approach is to look through the list of standard library modules that come with Python and think of things you could write with them, then write those things. I have written a few small utility applications just because I discovered a particular module that I hadn't known about before.

Omnifarious
I agree with the suggestion to stick with the standard library if you're just starting out. Perhaps instead of the "pick a project, then find out what you need to create it" approach, you should try it the other way around. Dig through the [Python Standard Library](http://docs.python.org/library/), get to know what it consists of and what you can do with it. Maybe a module will jump out at you, as being something you'd like to play with. Then you can write something around that module. (+1)
Andrew
I second Andrew's comment and would add that starting small is the way to go. Don't try to make big and complex projects when you are just starting out. By coming up with small, manageable projects, you will get the feeling of accomplishment more often. Then you can look for ways to bring your smaller projects together if you like. I say this from past failures in trying to start a really big project before I was experienced enough.
Justin Peel
This is how I familiarized myself with C/glib, just look for cool modules and write small programs centred around them - it good practice coding and using documentation as well as familiarizing yourself with what's out there.
zdav
@Andrew - I agree, I also think that's a good approach. There's a utility app or two I've written just because I discovered the `imaplib` module. :-)
Omnifarious
+3  A: 

Find a project you want to accomplish. Start planning it and everytime you wonder how you could do one specific thing search the net, us, whatever and get it done. In time you will learn tons of modules without realising it. Just going out there and looking for code is tedious and misses a good motivation.

Iznogood
+7  A: 

You’re asking in the right place.

When I was learning python I found that just about any time I got frustrated was a pretty good indication that theres a better, easier way to do it.

Break down your project into tasks, and when you're working on a particular task and you feel frustrated just ask here, "Is there a better way to do x?" You'll get pointed in the right direction fast enough.

Also, if you want to read up on modules the python documentation is good, but Doug Hellmann does the "Python Module of the Week" which gives a more detailed breakdown of each module and it's funcitons:

http://www.doughellmann.com/PyMOTW/contents.html

Browse through and dig in.

monkut
A: 

Whenever I get a new language to run I try to build something in it. Something that I need or want for myself. Its usually a small simple project.

I don't care about the functionality that the language offers in terms of its modules and so on. I just try to understand and play with the language at first. Then, as I grow comfortable and find myself doing something really hard to do something simple (say combining paths - I'm trying to do a whole bunch of work to figure out the directory separator) I google or ask someone - is their a simpler way to do this?

That's how I start getting more and more familiar with the tools and libraries that come with a language.

Finally, as I read more and more code in the language I understand the language equivalents to do something. E.g. I may not write list comprehensions right off the bat in python, but then while looking for say a way to combine paths I read some code that uses list comprehensions and I now know how to do those.

Just my 0.02ps.

obelix
A: 

Come to the dark side and learn Ruby/Rails. :) Seriously though, maybe the Python/Django world has an equivalent, but Rails Mentors is a new site to hook you up with a volunteer that can help you learn Rails. Programming is primarily a solitary activity, requiring a good amount of your time to learn and practice new technologies. Sure there is pair programming and I've worked on several teams, but in the end you have to do a lot of work by yourself. You also get the satisfaction of building something though! There are lots of learning resources: IRC, blogs, tweets, github. Read books, try tutorials, practice. Start a web application and choose one piece: logging in for example, focus on just that piece until you have it, then move on to something else. Build on what you learned, take it step by step. Try making something small, try releasing it. No one cares? Ok, learn something else, try again. :)

Andy Atkinson
So, halfway through learning one language, he should switch to another language? Heh! That Rails Mentors thing looks like a great idea.
Paul D. Waite
+3  A: 

Regarding 'knowing' which functions to use: just keep going. It'll be a long time before you're familiar with all the wonders of the standard library, and at that point you'll have started using 3rd party libraries too. The most important thing is that you get used to searching for information. Searching places like Stack Overflow, PyPi, and comp.lang.python (on Google Groups if you don't use Usenet normally) will turn up most of the answers you need.

As for the complexity of programming, you are unlikely to learn that by experimentation alone. In such cases it's often best to read a book or two on general programming advice, and sometimes to ask for outside opinions on a recommended program structure.

And as for Django: many open source projects have instructions that are "too nebulous", since nobody is paying these people to write great documentation. But unfortunately nobody has a magic wand to teach you how to understand the existing docs either. The best thing for you to do is ask about the things you don't understand. Django has mailing lists you can use, and there are probably other places you can ask too, eg. here. After all, almost everybody who uses Django at some point has installed it at least once. Don't be too proud to ask for hand-holding at this stage; several people will be glad to help get a new guy into Django.

In summary:

  1. Keep programming until you hit a problem.

  2. Search the usual sources for solutions.

  3. If you don't find a solution, ask someone about your problem.

  4. Make sure you understand the answers you are given.

  5. Implement the solution.

  6. Repeat from step 1, slightly wiser. :)

Kylotan
A: 

If you’re having problems with the Django documentation, phew — I think it’s regarded as one of the better-documented projects around. If you’re having any specific problems with it, you should be able to get good answers quickly here on Stack Overflow.

In terms of what modules are useful for specific tasks, Programming Python by Mark Lutz is a good guide at the nuts and bolts level. The fourth edition, which covers Python 3, is out in October, but the third edition should still be useful.

Paul D. Waite
+1  A: 

I cant really make out how much Python you know, but here is how I started with it.

Like you, I too knew that web was where I wanted to end up, since that is what I really want to do. So I chose a framework (Django) and got started. In fact one of the main reasons I chose Django, was the very good documentation.

If you don't know it by now, then I suggest a read through of http://djangobook.com

I knew almost no python when I started, I had not even read through the first tutorial on python.org, but after reading through the django book, I was ready to get going.

It teaches alot of Django and in doing so, it teaches you enough Python to get up and running. Because, when you get down to it, most of the websites that is out there, and most of the sites/apps you will ever make, is just basic CRUD. And after reading the djangobook, I was more than ready for that, so maybe you will be too?

And, as has been said already, keep coming back to SO when you feel like there should be a better way to do something, it will really help alot.

Best of luck and hopefully many prosperous projects to come.

Mathias Nielsen
A: 

I personally believe that simply reading books on programming is not going to cut it. In order to internalize the needed skills, you have to create a real problem for yourself. Having a real project that you actually want to complete will keep your more motivated than any book.

Also, I'm amazed that nobody has mentioned #python or #django on irc.freenode.org for help. I personally annoy the hell out of those guys on there.

When looking for a project, you may want to read Practical Django Projects. As you are trying to get into web development, it has all the basic projects needed for Web 2.0 (building a CMS, a social networking site etc.). Make sure that you follow the basic ideas outlined in the book, not just copy it down word-by-word.

Uku Loskit