Ask HN: What is a good, simple project for teaching yourself Python?

I am technically savvy but do not know any modern languages. What type of project is a good place to start?

Also: Are there ways to avoid purchasing a domain and getting a server and such going? What is an easy way to run the code locally?

  • This type of question is asked a lot, so I want to begin with the disclaimer that everyone is different and the real best project to begin with is something that you have a personal interest in, or that helps you professionally. For example, I taught myself jQuery by creating http://sleepyti.me -- which is now profitable enough to pay my rent.

    If you don't have an immediate need for software -- whether it be a webapp, or (more likely with Python) a script that organizes files on a *nix system, you have two viable choices: open source contributions or 'challenges'.

    Open source contribution is by far the best way to propel yourself into software development, but the problem is that it can be very advanced for the neophyte programmer. If you can find a project to take you under their wing, that's awesome; more likely, you can set this as an eventual goal of your programming experience.

    A second choice that I personally have found intriguing is the 'challenge' approach. Completing challenges such as Project Euler or various Code Katas that you can find (don't worry if they're in another language specifically, you can simply use your language of choice to complete them) shows progress and presents you with real, challenging scenarios to deal with. Code Katas tend to let you learn the language most practically, where as Project Euler problems are generally more math and algorithm-development based. Either way, these challenges are fun and generally rewarding.

    I wish you luck on your question to master software development; there are few feelings in the world as satisfying as creating a useful, clean piece of software.

  • My first Python app was a Windows automation script that took a data dump from SQL Server and ran it through Tableau's data visualization software, to produce a daily report on various metrics our company was interested in.

    The enterprise Tableau product was outside our price range, so this was a good way to hack together a solution using the desktop version and our raw data from SQL Server. As it so happened, Python turned out to have the best libraries for working with output from SQL Server, automating the opening and control of the desktop Tableau app in Windows, and then formatting certain Excel output appropriately (some of the data was graphs, some of it was direct output to Excel in a complex pivot table format).

    Python is really powerful for a whole host of things. As people have pointed out, choose a project that you want to get done, and then start coding it. I have never liked just trying to cram through an entire O'Reilly book, for instance. It's kind of like reading an encyclopedia cover to cover. Much better to focus on a problem that might incorporate a few different competencies.

    Personally, the tabbing in Python drives me nuts. Working in it convinced me that I really like brackets. I'm sure I'll get flamed for this comment, but I think it's just a mental processing thing. Some people work well with white space (VB being another example), others don't. I've always liked being able to use brackets as a reference point. Whitespace doesn't do it for me, even if I have the tab characters show up in code.

  • Everyone here's already given solid advice to you, so I'm here to offer my two cents from a slightly different perspective.

    In "Outliers", Malcolm Gladwell points out research that indicates there are three requirements for a job to be satisfying: "autonomy", or you getting to decide what you will do or how you will do, "complexity", that the job is full of tasks that engage you emotionally and intellectually at a "Goldilocks" difficulty level (not too hard, not too easy), and "connection between effort and reward", i.e. the harder you work the more you get rewarded.

    In my experience, while learning new programming languages, frameworks, and software engineering concepts, since my learning happens in my free time I have bucket loads of autonomy but I often misguage the complexity level and sometimes fail to offer myself any opportunity for reward in the long run.

    Hence, here are two more pieces of advice. Firstly, work on a real project, ideally for a person in real life. Someone who breathes, feels, and is willing to drink coffee with you. Ask _them_ what they want, tell them you're trying to pick up a new skill and want to help them out! What better connection between effort and reward can there be than helping a real person? (I hear people saying "money, money, money!", and yes I hear you).

    Secondly, start at rock bottom and learn everything from scratch. Assume you know nothing. Be the proverbial empty cup; a student approaches a Zen master with a cup and says "Master, teach me everything you know!" and the master proceeds to fill the student's cup with tea until it starts to overflow hot water onto the students hands. The student looks confused until the master responds "How can I fill your cup when it is already full?". Then, once you get started, offer yourself increasingly more difficult challenges and concepts. Continually progress your knowledge. Even in a language as sublime and as easy to initially use as Python there are always more concepts to learn, more elegant approaches, faster methods.

    Good luck!

  • Starting with the simplest idea you have in your mind will be the best way to learn python.

    Let me share my story, I started thinking about learning python two months back. My brother has been using python since last four years, so i asked him how should i start. His answer was simple "Learn it by doing". Stumbling with different ideas for a week i came up with a simple idea to write a script that collects publicly shared videos in facebook (I love viewing videos shared in facebook). I have been programming since last 8 years but this was first time i wrote a script in python. I got very excited when 20 lines of python script collected thousands of videos shared in facebook. Next day i shared my script and results with my brother. He was really excited and i asked him to help me to extend the project to collect the interesting videos shared in social media. After the iterative process of learning and refinement of idea, we built http://lolzwow.com.

    My idea of learning python by writing simple script that collects videos evolved into a complete site that collects and features Funny, Amazing, Inspiring and Interesting videos shared in web. On top of all i learned Python (one of the most beautiful language i have encountered so far)

    By sharing my story, I want to say

    1) Start with simple idea that can be converted into computer program

    2) If you have someone who knows about python, ask for help

    3) If you have any questions that confused you, join python IRC on freenode. From my experience, I can say people in python IRC channel are the most helpful people that i have encountered in any IRC channel. I really love python folks out there in #python channel.

    4) Learning by doing encourages you and highly reduces static friction that every people faces when learning new thing.

    If you don't have prior knowledge of programming I suggest to go through Introduction to Computer Science and Programming video lectures made available by MIT OCW http://bit.ly/bdRzad.

    Good luck.

  • This is the holy grail, great video tutorials.

    http://www.youtube.com/watch?v=tKTZoB2Vjuk

  • I always write Pacman in a new language to teach myself that language.

  • If you want to do web development, the google app engine is very good if you just want to "dive in". The dev server just works, and you can start a small project for free.

    Just be aware, the App Engine is not a great choice for every project. Simple things are really easy, but moderately difficult things are damn near impossible. But it's a good way to get started.

    Don't let that put you off though. You need to learn a heap to do web dev, and anything that cuts down the initial complexity is a boon.

    They purposely force you to write google-scale code, which isn't necessary for an early stage startup. If you hit the ceiling of what you can do easily, you will have to switch to django, or do some hardcore appengine stuff - don't write too many relations, just denormalize. Want to keep a counter? Bad idea, use sharding. Want to sum up a database column? They advise you to use map-reduce. It's all good advice for a super-scale app, but you probably don't need it.

  • IMO, starting with Django or App Engine or the like to learn Python is like learning to write poetry in French before you have the basics of French.

    I think it's best, for N days, to focus just on Python itself. Learn the basics of the language. Then for another M days work on a simple problem that's meaningful to you. Iterate, and play around with different ways to accomplish parts of your program in Python.

    Then learn a framework or CMS or javascript library or whatever you like.

    My first Python program extracted email addresses and names out of any of one's imap accounts' messages, and put them in ldif format, ready for import into any email client (that understands ldif). I already knew a bit about imap and ldif.

    I learned the basics of Python, data structures, list comprehensions, unit testing, etc. As a newbie I went overboard on different coding techniques, but that was partly the point, in addition to creating a working program that was useful to me.

  • http://learnpythonthehardway.org/ - the word "hard" not meaning "difficult" in this situation.

    Or do you mean you do know Python and want an open source project to work on using what you know so far? The wording of your question is ambiguous.

  • I good project would be something related to your work to say increase productivity or enhance something. I started python doing automation scripts for PSS/E ( simulation program for electric power systems). Or create a game - sudoku perhaps. The point is start doing something and the learning goes along with it.

  • I'm teaching myself to code and blogging about my journey. I write about some of the issues you mention like how to get a domain and set it up and all that. It's not that difficult but it looks hella intimidating doesn't it? Anyway, you might find it helpful: http://pragmaticstartup.wordpress.com/2011/02/13/how-i-am-le... and http://pragmaticstartup.wordpress.com/2011/03/24/how-i-am-le... ->this probably more relevant because I talk about the first few apps I worked on.

  • Don't forget http://www.pythonchallenge.com/

    You learn by solving riddle-like puzzles and then applying functions from the standard library once you know what to do. The riddles make it memorable and more of a 'doing', discovering process so it will stick in your mind more. You'll do stuff like write scripts to query web servers and log the responses.

    Also for just getting started have a look on YouTube for Stanford Programming Paradigms with Jerery Cain, I think it's lecture 24 where he introduces Python to the class and gives a very good run-down of the language characteristics, demoing with the command line shell.

  • I'd suggest trying out Google App Engine: the SDK runs locally on your box, but it is very easy to publish it to their servers for no charge.

    I think it might be a good starting point because it is so self contained, one of the toughest things with starting a new language is that so much of the documentation seems like an argument over the "right" way to do things or which library to use to perform some function.

    With GAE it is all in one place, the documentation they offer is solid and because the environment is so set it is easy to ask and get help.

    http://code.google.com/appengine/

  • I'm surprised no one has mentioned that you can just launch Terminal.app on OS X and enter 'python'. Or edit a file, save as <file>.py, run it through "python <file>.py" to see immediate results.

    A little more complicated: download the Google App Engine SDK, start developing Python webapps on your workstation. You don't ever have to deploy it if you don't want to.

  • If you already know the basics of programming and have any interest in web development, give a framework like Flask or Django a try. Neither of those really obfuscate Python much and both have great documentation. Even if you're not into web development, I would still recommend looking into a web framework, just to learn a bit about MVC if nothing else.

  • For learning the nuances of a language fairly quickly, I recommend http://projecteuler.net/. Start at number one and work your way up. You'll learn a lot about the language in just a few short exercises.

  • This is what I wrote to force myself to learn Python: https://github.com/rofrankel/mingal

  • Incredibly generic advice here, but why not build a simple blog app - you would only need a handful of db tables, and would learn a heck of a lot!

  • If you don't want to deal with the internet, try pygame.

  • The first project I worked on where I felt like everything sort of 'clicked' with Python was a client/server based application, in which I wrote both the client and server.

    I had a simple server daemon that ran on systems I was maintaining at the time, which would gather obvious statistics for system status where, in most places, you'd just be able to install munin, or some other OS monitoring utility, but I couldn't, for reasons I won't bother getting into.

    Instead, I was perfectly okay to write a server that listened on an arbitrary port, and a client that swept through all the registered servers, getting information from them and displaying them in a GUI.

    This had the added benefit of reinforcing my understanding of UDP/DGram, which are probably still weak, but definitely better than they were.