How to Learn to Learn Python
by Dan Haggard
A reader on my post about why everyone should program asked me for some advice on the step I took to learn the Python programming language. So I thought I might write a little guide for those who think they might be interested in learning Python.
This guide will be a little unusual by most standards – and it won’t be for everyone. It will be for those who are vaguely interested in learning to program, but aren’t entirely sure if it’s for them. It’s for those who have perhaps tried before to get into it, but couldn’t sustain the discipline or motivation to keep going. Those who often hear stories about people getting addicted to programming but never could understand why themselves – such people might get something out of this guide.
But I don’t want to suggest that everyone should follow this approach. In fact, if you are a person who is able to sustain the motivation to work from scratch through all of Zed Shaw’s: Learn Python the Hard Way, then you really shouldn’t bother with this post. Stop reading and start working. You don’t need me. He’ll teach you Python far better than someone like me ever will.
But there is an assumption underlying Shaw’s book that I do want to challenge: that teaching yourself something like Python is a matter of brute force willpower. I disagree with this. I do believe that for a lot of people, there are ways to structure your learning experience that will greatly increase your likelihood of seeing it through to a profitable end before you give up in boredom or despair.
(However, I think it’s worth pointing out that I entirely agree with his statement about the purpose of learning to program that he states at the end of his book.)
Really, I won’t be teaching you Python, but will be offering a perspective on how you can learn to learn Python. I also hope that throughout the course of this exposition, I will be able to convey some of the sense of why so many people find programming to be such a transformational experience. I really feel people need to be able to get a sense of this in order to sustain the sort of motivation they’ll need to see it through.
In any case, I hope this guide will prove helpful to someone out there. So let’s get started.
Step 1 – Figure out something that you want to build
This first step in learning to learn Python is unfortunately going to be a massive catch-22 for most of you (assuming you fit within my target audience). It is by far and away the most important step of them all. If you can’t figure out something that you want to create using Python then when it gets hard you’re going to quit. But here’s the rub: if you haven’t been exposed to programming before then you likely have no idea the sorts of things that you could build.
If you’re lucky then you won’t have this problem. Maybe you have been brimming with ideas for years. Maybe you’re a non-technical co-founder of a start up company that knows a lot about what coding can do – just not how it does it. If that’s the case then great! You have already gotten past the biggest difficulty people have with learning a new skill.
But I think it likely that most of you won’t fit into that category. At best, you have vague ideas about reducing the drudgery in your life, or expanding the possibilities of your self-determination. If this is the case then you need some concrete strategies for getting beyond this chicken/egg problem.
So that is what I’m going to provide you now. When you start on step two (below), and begin your very first efforts at learning Python it will be vitally important that you ask yourself these two questions in tandem:
What can I build with this?
What do I want to build?
Seriously – ask these questions over and over again. Once you finish reading another page of a Python book that you are reading/working through, ask yourself again. Write out your answers if it helps you to remember to keep asking. Shout them to the world. Do whatever you have to do. It’s that important.
In fact, I don’t think I can emphasise enough the importance of this process. Many of you are not going to believe me. You’re going to get all Jabba the Hut and dismiss it as an old Jedi mind trick. If you do – then you’re going to fail. You’ll get bored and give up.
Why is it so important? There are a number of reasons. The first is that the core of your motivational drive depends on you reaching the stage where your answers to these questions are exactly the same. Until that time, you’ll be relying on your will power to drive you forward. And here’s a fact of life – most of us have very little willpower. So it’s a race against time to reach this point before your will power runs out and you give up in frustration.
But why does our motivation depend on achieving this unification of answer? Because in effect, by achieving the same answer to these two questions, you are unifying two different parts of your brain. Well, to put it more precisely, when your answer to these two questions are the same, then you’ve succeeded in getting these two different parts to work in concert.
You know the old clichés about the head and the heart? One suggests that it’s a good idea to pay attention to teacher and get straight As, while the other is screaming at you to catch a glimpse of teacher’s boobs. The two forces rarely seem to work together. Well, it only feels this way because you’ve been raised in a society that knows better how to educate dogs than it does its own children. You give your dog all that it wants (your affection and maybe a tasty treat) when it uses its conscious mind to restrain its own impulse. You were given – what – a red tick? A gold star? Promise of a good career in 25 years when really all you cared about getting back to your xbox and getting the next high score?
The modern education system seems to have forgotten that while the conscious brain did partly evolve to allow us all to enjoy the superb witticisms of Stephen Fry, it mostly evolved to aid in the satisfaction of desire. The fact that our desires seem to go against our conscious determinations is largely a result of a perverse culture that mostly isn’t interested in satisfying your desires.
I’ll come back to that issue in a moment. The point is that in order to achieve true motivation you need to be able to link up in a concrete way this very line of code that your writing right now to some desire that you want to satisfy. You have to be able to see how this line of code fits within the entirety of your ambition.
This might sound far fetched – but I can in fact make you an iron lock promise on the matter. Assuming that you get to the point where you find the same answer to both questions before your will power gives up – then what I can promise is the fact of having this same answer will feel exactly like being able to tie this very next line of code that you’re writing into the grand ambition of your life. And having this sort of concrete understanding of how it is your conscious knowledge of the code fits into the web of your desire is going to blow the roof off your mind.
Why? Because it’s likely not a feeling you’ve ever had before – the feeling of your conscious and lower minds truly working in concert together. It’s an incredibly wonderful feeling. I think that this is one important sense in which learning to code is a genuinely transformational process.
But it’s more than just this – and you have to pay attention now, because this is the most important point of all. When you start asking yourself the second question (what do I want to build) – your answers will likely be vague and amorphous, completely unrealistic and probably unattainable by any modern man. The process of trying to find the links between what you can build and what you want to build ends up shaping your desires and making them real. Because really – and here’s a truth about yourself you probably never even guessed:
You don’t have any real desires at all… (at least, you probably don’t have very many)
Think about this – and let it sink in for a moment. Take a breath. Pause… Now let all the questions you have explode to the surface of your mind.
How can he say this? What presumption! I have desires all the time. I want a big house. I want an arse like Pippa Middleton. I want to sing and dance like that blonde girl on Glee. I want to look like Brad Pitt.
Sorry, but these aren’t really desires at all. They are like the shadows of desire – pallid and vague abstractions that are completely disconnected from your concrete reality. A better name for them is ‘urges’. Real desire is more like the gestalt of all these shadows – these urges – added and subtracted from one another. You want to screw that girl from marketing, but you don’t end up asking her out of fear of rejection. Well, your action (or lack of it) determines a sum where the fear of rejection and humiliation is subtracted from the urge to get laid with the former being greater than the latter. You really don’t want to screw that girl, because you aren’t prepared to accept the possible costs involved in achieving that aim.
It’s understandable that most of us mistake urge for desire. Our entire culture is geared to encourage us to indulge endlessly in the fantasy of our urges. Our fiction industry, our film industry – computer games, television, celebrity magazines – all of it designed to allow you to live an endless wet dream filled with tepid, shadowy urges. Why bother expending the effort to require real power when you can ride along with Harry Potter as he waves a phallic wand in the general direction of Voldemort’s cock?
All this exists to so as to stunt your real desires. It exists so you go to your job on a daily basis and allow the numbness to wash over you like a sea full of soma. What’s more, and this goes back to the point I was making in my previous post about why everyone should learn to program – given that all of the interfaces with which we use to do anything at all have generally been handed down to us from somewhere far above us in the great institutional hierarchy, and given that we largely obey the social rules that determine opprobrium or appropriateness in various social settings – it turns out that most of what we do is determined for us by forces external to our own motivations. Since desire is constituted by what we actually do and not by those urges about which we fantasise – it follows that we actually have very few desires, if any, of our own.
But what has any of this got to do with coding and learning Python? Because when your answers to the above two questions match, you will be but a single step away from converting a vague wispy urge into a concrete and achievable desire that you can actually satisfy. The urge will no longer be wispy and vague because they’ll be shaped and moulded to the fundamental and absolute laws of physics that underwrite computer science. You won’t necessarily understand any of these laws. But you know that they will be in operation because you know that these laws (whatever they are) are what make computers work – and learning to code is learning how to make these computers obey your commands. So if your two answers match – if you know you have a grasp of the code needed to build something that you want to build – then you know that your desire is not just a mere fantasy – not just a shadowy urge, but is in fact something that is concrete, real and attainable. All you have to do is write the damn code.
This story that I’m telling is an exaggeration in one important sense. Unless you are some kind of Mozart like savant that can visualise all the notes of the sympony (read: lines of code) in his head before he actually writes it – then likely your two answers will not entirely correspond with complete exactitude until you’ve actually written the code. Always there are gaps in the steps between here and there. You won’t always know for sure that you’ll be able to cross those gaps when you reach them. Sometimes you’ll run into problems you can’t solve. Sometimes there will be chasms too large to cross.
The trick is to not worry about them until you reach them. If you fret about ensuring you have the complete symphony playing in your mind before you write a single note, you won’t actually ever write anything. And of course, the flexibility required in adapting your vision to the limitations of your problem solving abilities is the most wonderful aspect of hacker sensibility. At the same time, however, sometimes its important to stay true to your vision if you desire it enough. Sometimes you have to stick at a problem because your vision demands it. Finding that balance comes with experience.
There is one further aspect of this questioning process that I think explains the frustration that many developers have in working for their clients. Because most people haven’t trained themselves to make their desires concrete, developers end up having to play mid-wife to their desires (and they hate this). They get handed these vague specifications for an application that literally doesn’t make sense when thought about in terms of how the project is to be actually built. The developer has to spend an enormous amount of time explaining what is possible. They have to constantly battle the urges of the client that refuse to be tempered by reality. The client becomes frustrated that the developer keeps trying to change what was wanted, whereas the developer knows that the client likely wouldn’t want that for which they ask if they knew a little bit more about what they are asking.
By learning to code, you’re training yourself not to be one of these people. By learning to code, you are training yourself to turn away from your urges in order to satisfy your desires. And this realisation will spread to every aspect of your life. It will change you – fundamentally.
Step 2 – Start the grunt work and learn the basics of Python
Now for the hard bit. You know in the abstract about how to approach your learning. It’s now time to sit down and start doing it. You need to learn the basics of the Python language. This is the most dangerous period for you – because your motivational core is as yet unformed. It is nascent and vulnerable in its cosy womb! The key is to move as fast as you can to the next stage. The secret, surprisingly enough, is to learn as little as possible. I’m going to explain what I mean by this and provide some strategies that will help.
First of all – what do you need to know? You need to learn how to install Python. You need to learn how to fire up the Python interpreter (a vital tool that allows you type in code line by line and get an immediate response). You need to understand what a module is and how to import them into your code. You need to understand how to install libraries (you’re going to be doing this a lot).
You need to understand the fundamentals of the syntax, variables, the basic data types (lists, strings, dictionaries, numbers, tuples, files) and some basic control control flow operations like conditionals, loops. You need to understand functions – and for extra credit you can learn the basics of what a class is – even if you don’t get to the point where you can successfully use them yourself.
As I said, the secret to this stage is to move as quickly as possible, and learn as little as possible. This sounds counter intuitive – but trust me. You have to get to the next stage as quickly as possible. What you need is get is a broad understanding of the language. You need the gist. And you need this so you can start forming answers to the above two questions. If you spend two weeks working through examples on string methods – learning every method that the standard library has for strings – you’ll be awesome at string manipulation – but crap at understanding why on earth you might want to use these methods for something in your real life.
What you want for this purpose is a straightforward reference book – something that is actually quite light on examples and exercises. For this purpose I personally used “Learning Python – Fourth Edition”. But I’d be keen to hear other suggestions (i.e. something that covers the basics quickly and in much shorter time). Read up to and including Part V. But OMG – that’s over five hundred pages! Well – don’t read every page. You won’t need to read every chapter. You won’t need to read every page of any chapter. If something bores you – skip it. If you don’t understand something – skip it. Try out a couple of examples on the interpreter – but don’t do too many.
Don’t worry about the higher order concepts. You will need to know that 3 + 3 will output 6, and that “3″ + “3″ will output “33″ – but an understanding of dynamic typing itself can come later. You will need to know that a variable declared inside a function can’t be accessed outside that function – but you don’t need to know the details of name spacing, or why it’s important. Read these sections cursorily. If you go for extra credit and start reading about classes – you probably should understand inheritance – but don’t stress about encapsulation. (But I don’t mean to say you should never learn these things – once you’ve got the bug you’ll be able to bring yourself to attack just about any higher order concept you like)
Many seasoned programmers will be likely frothing at the mouth right now.
Don’t do many examples? Skip name spaces, dynamic typing? Skip encapsulation!?! How can he advocate this? A student must learn the fundamentals or he will be forever undoing his bad habits in the future. He needs to work through example after example after example – as doing programming is the only way to learn programming.
But this is not the right mindset for us – at the very least. And I could even make the case that it’s not the right mindset for good (independent) learning – period. Remember, we are in a race to reach a certain goal before our brain decides that this isn’t profitable and declares boredom. We don’t have parents or teachers to chastise us if we fail. Most of us don’t have the promise of a glorious coding career ahead of us. We need to motivate ourselves, and what I’m giving you is the best method I know for achieving that motivation.
What’s more – what I’m teaching you is actually a much more efficient system for learning than what we were taught at school. This is because our traditional learning systems seem to fundamentally ignore what the brain is good at – and what it is not good at. And we need to understand a bit about this before we go any further.
Let’s start with what the brain is bad at – details. It’s woeful at remembering specific, isolated details. Dates, places and names – isolated historical events – a particular method for finding common factors in algebra – a particular method for sorting lists in Python. To learn such things you do indeed have to repeat them to yourself over and over and over. And it’s not just that the brain is bad at remembering the information – it’s that the brain will send signals to you, trying to make you stop trying to learn it. That’s what boredom is. The only reason why we manage to learn all this boring stuff is that institutions arose to punish us if we didn’t practice them endlessly. Society found a way to impose motivation from the outside – resulting in our collective misery. But hey – I’ll agree it’s better than no learning at all.
Anyway – this tendency to boredom is just the brain being efficient. We evolved to avoid trying to learn stuff that we aren’t likely to use. Because if we aren’t likely to use it – then it’s just wasted effort and is actually impeding survival. The brain will do everything it can to avoid such tedium and to forget whatever is learnt through it – to free up resources for more important things. But if the brain can easily make the connection to a real world use that works toward the satisfaction of desire – then just watch how fast it locks down even the most difficult to understand piece of information.
Which brings us to what brains are good at. They are good at seeing patterns – connections – links. They are good at narrative and story telling. They are good at systems and the gestalt (even if the gestalt must be a convenient fiction). Most importantly, they are good at indexing information – as opposed to storing it. By indexing information, I mean that the brain will pick a symbol (or a sequence of symbols) for the particular task or operation under study and it will assign a look up procedure which helps you track down (in the world) the specific bit of information being indexed. But it will more often than not forget entirely the actual bit of information itself. I don’t understand the exact mechanics of it – but presumably this is just a hell of a lot cheaper in terms of storage and effort than keeping the actual information being indexed.
It’s exactly this process which explains why it is that just about all of you reading know that there is such a thing as long division – and yet wouldn’t know how to actually do long division to save your life – assuming that you weren’t allowed to look up how to do it. Even though you were forced to do hundreds of the bloody things when you were kids – you STILL forgot. You remember that it’s math. You remember that division is the opposite of multiplication. You remember all sorts of things about long division – because they connect easily to a broader network of information you have built in your head about the world (information that you actually need). But that specific algorithm for long division is lost to you. But now imagine someone putting a gun to your head and commanding: “Long divide this! – but uh, feel free to look up how to do it.” You would know exactly what to do. You’d grab a maths textbook – or you’d google the method – and you would get the job done.
It’s this aspect of how the brain learns that is the most important with respect to the particular learning strategy I’m offering. And it’s also the reason why I advocated reading a straight forward reference book (as opposed to a coding cookbook and that sort of thing). While you’re reading – even if you’re reading very quickly, and without a large degree of understanding – your brain will be indexing information like a super computer. You won’t remember much about the actual syntax of the methods for manipulating strings – but you will probably remember that there is such a thing as a string, and you’ll remember most of the sorts of things you can do with them – like conjoining, splitting, changing the case… etc. You’ll also remember the approximate location where you learnt these things so you can quickly look up the syntax – if you need them.
The philosophy behind this strategy is to index as much information about the Python language as possible – while learning as little about the actual language itself. Why? Because you only need the index to be able to start answering the question – what can I do with this? You only need the index to be able to start forming the connections between your desires and the knowledge you will need to obtain those desires. Once you have those connections – learning the specifics will be easy. What’s more – you’ll spend more time building your first application – your application will be the embodiment of your practice. The aim is ultimately to practice as little on things that you won’t ever use. We want as much of our practice to be directed toward our goals as is possible. And we want to do it this way because that’s what will keep up motivated.
This fact about learning is so straightforwardly obvious to my mind that it astonishes me how the modern education system proceeds as though it is completely ignorant of it. (And this is despite the fact that most educators I speak to seem more than aware of everything I’ve just written. And this is despite the fact that most people – period – see the common sense in it immediately – if they haven’t thought it to themselves before).
Yet, our chief assessment method for students remains the ‘exam’. The exam requires that you can deploy the actual information from your mind without being able to rely on your brain’s natural indexing and retrieval methodology. That means thousands of hours of artificial practice procedures. That means the best part of our youth is spent on storing knowledge that is forgotten as soon as the brain realises what it will actually be doing in life. The best part of youth spent on activities that make you miserable and net you next to nothing beyond an index of information that you could have obtained in a fraction of the time. It’s a god damn crime.
Hopefully I’ve made the case. So go and do some reading! Keeping reading cursorily like this for as long as you can without getting bored (which for most of us won’t be very long). Keep asking yourself the above two questions. When you feel yourself starting to get bored, when you begin to wonder why on earth your bothering with this endeavour – then it’s time to move on to step three.
Step Three – Choose a Front End
Hopefully by this stage you have at least a vague impression of what you want to build and what you can build. At this point the gap between the two will still be quite large – but you will already begin to see the distance between the two growing smaller. If you still don’t have a clue about what you might want to build – don’t worry too much yet. It’s rare for most people to have gotten there by this stage.
But what about my motivation, you might ask. If I have to read another word of ‘Learning Python’ fourth edition – I’m going to kill myself!
Don’t worry – I know your pain. What you need now in order to keep you going are a few endorphins. Nothing like a shot of endorphins to get the coding juices flowing. To get these endorphins, all you need is to see various things pop up on the screen – fun, shiny things that happen as a result of your code. The brain is good like that – once it sees that your practice is having a real world effect of some kind it will reward you with happy-making endorphins as a sweet, sweet reward. It will even do this for a little while when it still can’t connect these events to the grander scheme. The rewards will stop if the connections aren’t made eventually, but the brain knows implicitly that is has to reward a little bit of experimentation and trial and error – otherwise we’d never get started on anything. So being able to make things happen on the screen is going to buy you a little time while you search for inspiration for your project.
So, for this purpose you’re going to need to choose a front end. By ‘front end’ I mean something which allows things to pop up on the screen – that’s all. The python command line interpreter is one such front end. And if you have been using it to practice the odd example, then you might have already received some happy endorphin juice. But the command line isn’t going to remain satisfying for long. The brain wants to see you manipulate a front end that resembles stuff it has used in the real world. For most people, this means a graphical interface of some kind.
(There may be some exceptions to this rule. If you already have an idea of what you want to build, and say that it has, for instance, something to do with say – natural language processing – then a graphical interface will probably be the last of your concerns. Your brain will forgive the lack of a shiny front end because it will see your efforts situated within a larger set of goals.)
Now – choosing a front end will be a lot easier if you already have a clear idea what you want to build. The great thing about Python is that no matter what you pick at this stage – there is almost certainly a library or a framework that helps you get to the stage of outputting to the screen relatively quickly. If you want to build a computer game – then Pygame is going to give you relatively quick access to a front end that you can use to meet your goals. If you want to build a desktop app of some kind – then there are a number of different options for you depending on your platform (http://wiki.python.org/moin/GuiProgramming). If you want to build a web application of some kind, then I personally would recommend Django – but there are also a number of different options here.
If you still have no idea what you want to build, then things are a little more risky for you. If you can stand it – go back and read some more. But if not – you have to pick something and roll with it. It’s crucial that you start making things happen as soon as possible. If necessary, learn the basics of one kind of front end and then switch to another to get a feel for what is possible.
In my case I wanted to build web applications. So I chose Django. What follows will largely be about Django because I just don’t have enough experience with other kinds of front ends to really be of help. Presumably a lot of people reading will be interested in the web as well – since it’s kind of the in-thing at the moment. So let’s proceed.
Step Four – Find a Django Skeleton (if one exists!)
Right – you’ve got the gist of how Python works. You’ve got a front end you want to use. Now it’s time to start coding and make things happen!
Well, actually – not yet. There is one big problem in choosing the web as your front end when you’re a first time programmer. You can’t make anything happen unless you know a little HTML – and you certainly can’t make anything look nice unless you know a little bit of CSS. Oh noes! Two new languages! We haven’t even really properly started with Python yet.
And to make matters worse, as awesome as Django is – it’s still something that has to be learnt. And most of the introductions to Djano will assume more Python than you can probably handle at this point (depending how far you got in step 2). And that’s a problem – because at this point of time your brain is starting to shut down out of pure boredom and frustration. It needs an injection of endorphins – stat!
What we need is a skeleton Django application that comes ready made with an HTML template (plus css) – as well as the usual views.py, urls.py, models.py with some basic examples in there ready to go. All the code would be nicely commented so it’s dead easy for the newbie to see at a glance how to make the browser screen output different stuff by changing things in the views.py file.
The purpose of the skeleton would be to make it as easy as possible for Python newbies (and not just Django newbies) – to use the browser to test and experiment with their code. The quicker we can get them to this point – the more likely a love of coding will take – since it’s just so much more satisfying to see things happen in a real environment.
I’ve had a look on the internets for such an application – but I haven’t been able to find one. If someone knows of one, let me know in the comments and I’ll link to it here. Failing that – as soon as I’m done with this post I’ll look into making one myself and make it available here (no promises!).
In the meantime what can you do? Well – you’re still going to have to install Django. You can learn how to do that here:
If you can stand any more reading – just keep going with that reference as far as you can. In this case you should start working through all the examples as it pretty much takes you through the process of setting up you first django application.
You won’t have to worry about learning how to deploy a server and all that sort of thing for a while as Django comes with a handy server application that will allow you to play around with your code and see it deployed locally to your machine.
As for avoiding learning HTML and CSS. Find a free HTML template off the internet and when you’re ready, use that to insert Django’s template tags. I recommend approaching the HTML and CSS exactly the same way as for Python. Get the gist as quickly as possible and then experiment in the context of building something that you want to.
Alternatively you could work through a very good book by one of Django creators James Bennett Practical Django Projects (Expert’s Voice in Web Development) (disclosure: affiliate link! Use it!). The cool thing about this book is that it will very quickly get you to the point where you can start outputting the results of your code to the screen, while also working through the basics of how Django works. Even better – it’ll actually give you some experience building entire Django applications. Even if you don’t start with this book, I highly recommend going through it at some stage.
But in my view – what would be ideal is a ready made skeleton. Because really at this stage, these alternative suggestions will be intimidating to most Python newbies. And yet – if they aren’t able to play around with something on the screen it will be hard for many to sustain their motivation. It seems to me that it wouldn’t be too hard to remove these obstacles so that after installing Python, Django and the skeleton, they could just type:
python manage.py runserver
…at the command prompt and see the application already up and running. Then all they’d have to do is open up the views.py file of the skeleton application and start manipulating the nicely commented code. In essence my suggestion is that rather than expecting people to know Python so as to learn Django – we should find a way to use Django to teach people Python. The idea is that they use the views.py file of the skeleton as a place to learn basic Python syntax and operations. From there they could branch outward into the Django framework learning pieces of it as they go to build richer and more complex applications (with the skeleton application perhaps providing gradated examples of greater complexity that students can graduate to).
Consider this analogy made by Zed Shaw at the beginning of Learn Python the Hard Way:
While you are studying programming, I’m studying how to play guitar. I practice it every day for at least 2 hours a day. I play scales, chords, and arpeggios for an hour at least and then learn music theory, ear training, songs and anything else I can. Some days I study guitar and music for 8 hours because I feel like it and it’s fun. To me repetitive practice is natural and just how to learn something. I know that to get good at anything you have to practice every day, even if I suck that day (which is often) or it’s difficult. Keep trying and eventually it’ll be easier and fun.
While I agree that if you have the discipline, and are able to approach your learning in the way that Shaw suggests, then a couple of hours of practice a day in either music or programming will eventually get you to your goal. But I disagree that the analogy between the two is actually all that appropriate. If you’re playing the piano and want to draw upon the notes written in one of Mozart’s piano concertos in one of your own compositions, then you literally will not be able to do it without the sort of practice that Shaw suggests. You won’t even be able to add a single bad note to Mozart’s composition, because you won’t be able to play any of it.
But programming is different. The fact is that I can add a bad note to an existing piece of code without ever having looked at a single line of code before hand. With only the most passing familiarity with the Python language, one could change a views.py file in a way that gets you a successful result in the browser – if things had already been set up for you. Will the newbies likely compose a crappy addition to this wonderful stack that is Django? Of course! But at least they are composing in the context that will most quickly allow them to reach their goals.
Step 5 – Choose an IDE
IDE stands for integrated development environment. Basically its something in which to write your code beyond just a mere text editor. Now there is a lot you could look for in an IDE. But what you want is something which doesn’t itself add another learning curve of difficulty. At this stage – you just want something that is going to at the very least highlight your syntax errors without getting in the way of you writing code.
To this end I recommend pyscripter (windows). It’s free and it’s easy to use. For other OSs – I don’t really know. So if anyone has any suggestions please feel free to leave them in the comments.
If you graduate to more complex applications then you may well want to use something more sophisticated. But more than likely Pyscripter will have way more functionality than you’ll ever actually need.
Step 6 – Set Mini Goals
Break up your overall aim into little mini goals. These will be little subsets of functionality that you can code independently from one another and then figure out later how to stitch them together.
Maybe your application will need to allow users to log in and display personalised information. Well – code up a basic application that does just this. Don’t worry about how it will fit in to the rest of your larger application. Just get it up and working. This is akin to doing an exercise in a book – except you’re creating your own exercises based around your own goals.
Achieving each little mini-goal will give you another hit of happy making endorphins and will contribute greatly to your staying power. You won’t lose your motivation because learning each subset of functionality is part of your larger ambition.
When you start out, your mini-goals are going to be very basic. Maybe your application is going to have to do some basic mathematical operations at some point. Write some! Maybe you’ll have to dynamically generate text for an email sent to your users. So write a quick script that concatenates strings. Etc…
The next task you pick should be as close as possible to your current skill set while extending it by a single degree. Don’t write your first string concatenation and then set as your very next task the creation of a snazzy ajax powered webform. Learn to distinguish between the small goals that you could accomplish in the next day or so – and the larger long term goals of which they form a part. Constantly be thinking about how the former fit within and contribute to the latter.
The particular task of breaking up tasks is in fact itself a crucial skill in software development (as well as life in general). May as well start working on your abilities in this respect from the very start.
Step 7 – Keep Your Eyes on the Prize
Ok – so now you’re coding, and you made various cute little things appear in the browser as a result of your code. Now’s the time to re-iterate to yourself your reason for doing this. What do you want to build?
Every bit of code you write now should already be working toward your aim. Don’t learn some feature of Python or Django because some influential hacker wrote on his blog that he doesn’t respect any coder that doesn’t use it. Learn it because it’s something that you need to learn in order to build the thing you want to build.
From now on, learning Python will be an iterative process where sometimes you’ll be experimenting with code, and at other times researching particular ways of doing things by googling, asking questions on Stack Overflow, or reading more books. If you proceed in this way, your motivation will always stay strong. Even as you’re trudging through some difficult documentation, you’ll be able to say to yourself, I’m working through this because I need my application to do X.
Write as little code as possible. Seriously. For whatever piece of functionality you are trying to implement – do a google search for an existing (open source) library. If there is such a library that does most of the work that you need to do, use it. Only start worrying about the magic going on under the hood if there is a problem, or the library doesn’t do exactly what you need it to do. And if it doesn’t do what you need, don’t start building the functionality from scratch, try to modify what the world has already given to you. Although you’ll be writing as little code as possible, you’ll still have to write a mountain of it before you are able to reach your goals. But hopefully you will have achieved your goal as quickly and as efficiently as possible.
You won’t be living to program. You will be programming to live.
Step 8 – Find Some Way to Give Back to the Community
That’s actually the last of what I want to say here about learning to learn Python. It’s no where near as detailed as I’d like it to be. It’s closer to an overview of what I’d like to write, which would be a kind of Python text book that walked you through the process step by step toward the goal of building your own applications for the web as quickly as possible – but underwritten by the kind of philosophy I’ve been outlining here. If there is any interest for this kind of book – let me know in the comments. It’s something I’ve been thinking about writing for a while, but knowing there was a potential audience would help with the motivation greatly.
As a final comment, I’d like to take a moment to emphasise the importance of giving back to the community if you ever get to the stage of building your own applications. The sort of approach to learning Python that I’ve advocated here would be impossible if not for the open source movement. Without the higher level languages, the awesome frameworks and libraries, it just wouldn’t be reasonable to expect a newbie programmer to be able to quickly get to the stage of starting work on their first application. It’s because of their work that we can now begin to think of programming as a non-specialist endeavour. Don’t just take from this generosity – find some way to make a contribution of your own.
Now folks like us – the non-specialist coders – aren’t likely to ever be able to write an open source project that helps others in building their own applications (at least, such a task is currently daunting to me although I’d like to be able to do it one day). But there are plenty of other ways one can make a contribution.
One easy way is simply to spread the word to your friends about the importance of programming and the difference it has made to your life. Show them how easy it can be. Do what you can to break through the mentality that people commonly have that coding just isn’t something they can do. (But don’t be an a-hole about it. The best way to convince people is to just build cool things that make your life (and theirs) easier).
And if any of them do take up coding, take the time to help and guide them. I have a very good friend who helped me greatly when I started to learn to code. He didn’t just give me examples of ways to write good code – he helped me keep my ego in check when I started getting cocky about things. He taught me always to try and approach your work with a humble attitude and to realise that there is always a better way of doing things.
Be like this, and we’ll all achieve maximum awesomeness a whole lot quicker.