Best way to bring my programming to the next level?
March 23, 2012 9:50 PM   Subscribe

So I've used Python here and there to solve system administration tasks and create some small web applications (again to solve any issue related to work). Living in the sys admin world, I typically turn to Bash. Bash because I know it well and I can throw out a solution quickly. Problem is I'm starting to interview more and more for "DevOps" positions, what's the best and fastest way to bring my Python (or insert language) abilities up a notch? I admit that I typically write in Python with one screen trained on the library docs. I've got a solid understanding of data and control structures. I thought maybe coming up with a weekend project might help but I'd like to hear other people's thoughts. Reading good code always helps, but doing is always better for me. I guess the real question is creating something that does x always makes you understand a language at a deeper level (if such thing exists).
posted by snuffaluffagus to Technology (11 answers total) 29 users marked this as a favorite
 
The best way to learn any programming language is to write lots of it, which is basically the same as for natural languages.

Take some of the bash scripts you've written and rewrite them in python. Ban yourself from writing new code in bash for a while, do the total immersion thing.
posted by tylerkaraszewski at 10:43 PM on March 23, 2012 [1 favorite]


Oh, and there's an answer to your 'x' question, but you (understandably) won't do it. Want to understand any language at a deeper level? Write a compiler for it.

But for most people, you'll want to use the language for the same sort of task you're likely to use it for professionally, hence my suggestion to rewrite your bash scripts.
posted by tylerkaraszewski at 10:54 PM on March 23, 2012 [2 favorites]


tkz (as I will refer to the previous poster) has the right idea. I would suggest not only getting a lot of practice by writing new things (and rewriting old things) in Python, but look into some things that will specifically improve your programming. Check out best practices, write tests for your programs, see if there are any Python koans out there, read good books (like "Learn Python the Hard Way") to gather what extra knowledge you can.
posted by cardioid at 11:30 PM on March 23, 2012


Throw yourself in the deep end - get a job as a python dev
posted by mattoxic at 12:30 AM on March 24, 2012


I think your idea (and tkz's suggestion) is the best approach— find a problem you understand and try solving it in Python. I somehow developed the habit of learning a language by implementing a network protocol in it. I wrote a DNS server in Python, an SSH client in Scheme, and an IMAP server in erlang. They're all fairly crappy as implementations, but getting something working to the point of being able to successfully talk to another implementation forces you to actually understand how to use the language in a way that textbook examples don't.

(And I've been coding in Python since the mid-90s and still keep one window open for checking the docs even for common library classes. It's quicker to do that than to go and iteratively fix things later when I misremember a method name or argument order.)
posted by hattifattener at 1:40 AM on March 24, 2012 [2 favorites]


Read up on Design Patterns.
posted by backwards guitar at 4:26 AM on March 24, 2012


Best answer: There are a variety of collections of programming problems out on the web designed to bring a programmer up to speed on a new language. I'll mention three here that I've used successfully in the past to learn an unfamiliar language:

15 Exercises for Learning a new Programming Language -- exercises are on the simplistic side, things like calculating Fibonacci sequences, sorting lists of numbers, and parsing HTML. Fits your "weekend project" criteria. I would start here.

15 Exercises to Know A Programming Language: Part 1 -- a response to the above link, these exercises are more challenging and take more time, but have more "real world" application. If you aren't a professional programmer already, this is a lot bigger than a weekend project, but even working through a few of the exercises would increase your scope of knowledge of Python.

Project Euler -- these are all pure math problems. You aren't going to learn about any of the APIs in Python, but this will get you warmed up on all of the control structures and logic facilities. Since you mention that you feel solid on all of that, I'm including this for completeness -- you will probably want to skip this one.

This question has come up on Stack Overflow before; more links and ideas there.

Finally, if I'm trying to learn a new web development framework (e.g. something to write web applications with, in the case of Python something like Django), I'll implement a toy version of a URL shortening service like bit.ly. This is a quick/short app to implement that gives you a basic grounding in a framework.
posted by kovacs at 5:02 AM on March 24, 2012 [7 favorites]


For python specifically, I would suggest turning your usual tasks into Fabric scripts.
posted by gregglind at 7:27 AM on March 24, 2012


I found this the other day which might be some help: Codekata.
posted by urbanwhaleshark at 8:58 AM on March 24, 2012


I was in the same situation except perl was my old go-to.

Projects which helped me learn python:

* Program where I enter passphrase and it decrypts the priv key and config file with various secrets and create a ssh-agent session with my cloud credentials in environment vars. Cleanup when done.

* Program using boto and libcloud to automate all cloud tasks and avoid use of the web interface.
It was a great place to learn how to use classes.

* Used Fabric to create little ssh-based jobs. For common larger tasks create python scripts which call these fab jobs. Use classes for abstraction to make the programs clean and extendable.

* Command loop which launches processes which bootstrap a new cloud host. The command loop acts like a little shell and lets me check status or tell it to notify me when parts are done (argparse, cmd are relevant python modules).

* To do: reliable "time out" library (I'm using one for internal work but it is GPL so I need to write my own so it can be used in externally-released software...)

Find some inefficiencies in your day-to-day work and write some
python classes to automate little pieces. Build up a library. Learn to use iPython for fast development.
posted by simongsmith at 9:13 AM on March 24, 2012


I think some of the advice in this thread is a little ambitious. You don't go from writing a for loop to writing a compiler, protocol implementation, or most of the project euler exercises.

To bridge the gap, I'd recommend working through whichever of these make you feel the most comfortable:
posted by outlaw of averages at 1:38 PM on March 24, 2012


« Older Lull me to sleep   |   Am I overreacting or righfully irritated? Newer »
This thread is closed to new comments.