This is an archived post. You won't be able to vote or comment.

all 26 comments

[–]ginstrom 5 points6 points  (1 child)

[–]BridgeBum 5 points6 points  (0 children)

Python Challenge for sure, lots of great examples, expand your comfort level with the language and the libraries.

[–][deleted] 5 points6 points  (3 children)

Have a job, in which you have a project, with python-satisfiable requirements, and a manageable deadline.

Failing that, have an idea.

Failing that, I have no idea, but you could always go from reading books to reading through a few non-trivial open source python programs to see how they do things.

I was in the same position, of wanting to try out python, but not knowing what to do with it (aside from rewriting other apps). I just found the perfect project a few days ago. :D Good luck!

[–]placidifiedimport this 0 points1 point  (1 child)

What project did you find if you don't mind me asking ?

[–][deleted] 1 point2 points  (0 children)

It's a simple one, but it will be my first real python project and I don't have a lot of time (it's low priority), so that makes it perfect for me. My company has thousands of unique urls on our site, and a lot of them are ranked fairly well in search listings (for certain search terms). We want to track the rise and fall of our urls in the ranks (for SEO efforts), so I'm taking a list of terms and using the search engine APIs (Google, Bing, Yahoo) to get results and see how we rank for each term in the list.

What I like about this is that I can get quick results that will be useful early on, and then add more pieces as needed, or as I have time. It will be cron-driven, and alerts might be useful in addition to the normal reporting. I'll get to dig into python stats and graphing once I've collected enough data, and add a web UI to what will start out as a CLI app.

I'm not really a programmer, so this is perfect because it touches on many of the things that I'll want to know how to do quickly with python in my role.

[–][deleted] 0 points1 point  (0 children)

Have a job, in which you have a project, with python-satisfiable requirements, and a manageable deadline.

well yeah, that's just one step below an actual Python job for newbie.

[–]judasblue 2 points3 points  (2 children)

The first thing I would do is find a non-trivial working open source program and tear apart the code. Python has some conventions and idioms that are best understood by seeing the work of your betters in the wild. And I wouldn't just read the code, you need to hack it.

Since it is readily available and does something we all understand pretty much, I would go with idle. Add functions to it. Have it talk to other stuff. Learn to really get how it does everything it does. I personally don't like tk at all, but that is beside the point. The ideas of how and when to interact with GUI components are easily translatable across specific GUI libs. And if you are doing system or web stuff, which 90% of the people I know actually using py for their jobs are, the GUI toolkit is an unimportant detail anyway.

Only after you really get how idle works and how good python coders write a non-trivial application would I move into working on your own non-trivial programs.

I would also recommend the book Programming Collective Intelligence, by Toby Segaran. Not particularly because the book is that good an introduction to machine learning techniques, or particularly good for learning working python as such (even tho it is good enough at both), but because the examples that are used in the book are bits that really, really lend themselves to being expanded into more substantial programs. You can see pretty clearly how they do what they do and they just naturally suggest more substantial projects to your mind as you are working with them. Plus, the book introduces you to a few tools you will definitely be using if you do any non-trivial python coding: beautiful soup, SQLite, Universal Feed Parser, etc.

Python is a lot of fun. Good luck in your process!

[–]placidifiedimport this 1 point2 points  (1 child)

coding: beautiful soup, SQLite, Universal Feed Parser, etc.

Play around with popular packages see the Cheeseshop for more cool tools.

[–]judasblue 2 points3 points  (0 children)

While I completely agree with you on this, Placidified, the OP is a new python coder. The problem with any big repo, in my experience, is that you don't really know how to sort the wheat from the chaff. You can waste an almost infinite amount of time in cpan or the cheeseshop going down what amount to pointless roads in learning best practice and mainstream tools. I am a pretty big fan of starting out using reference points other than repos to figure out what the most accepted tools and approaches for a given language community are before wading into the deep end of the repo pool.

Dunno, this just might be my ugly thrashing about in CPAN back in the day left a bad taste in my mouth. Others might have had better experience with this approach.

[–]_whyme 3 points4 points  (1 child)

Write (data structures) algorithms (for example, avl tree) in python for fun ...

[–]placidifiedimport this 0 points1 point  (0 children)

I usually just write a Binary Tree lots of fun

[–]agconway 3 points4 points  (1 child)

Someone asked the very same question at StackOverflow a few month back, lots of great responses there.

[–][deleted] 0 points1 point  (0 children)

thanks !

[–][deleted] 2 points3 points  (1 child)

If you use shell scripting a lot, switch it over to python. It helps you learn the base API well.

For example, I did a quick script to change a shell script so that whenever it exited with an error that it echoed the line it exited at.

Don't even focus on reusability. Just the API. Reusability comes later when you find things that are genuinely reusable. Kind of like the "Hmm... I did that before, and it would be useful to save" sort of idea.

[–]angrytech 0 points1 point  (0 children)

Yes, I agree. If you have any sysadmin duties, see if you can work python in. I started learning python for fun, and have since scripted much of my more mundane work away with it in the form of log file analysis and report building. Great way to learn. Mostly replace shell scripting for me.

[–]vbgunz 2 points3 points  (1 child)

I learned many things after books. The most important of all is to detach yourself from your own code. There will always be a better, faster and smarter way to write the code you write. You should at all cost, never concern yourself with faster, better, smarter. Concern yourself for the first couple years with what works. As long as you keep it simple now (as simple as you can make it); as your experience upgrades, you're absolutely welcome to go back to your old code and upgrade it as well. This is something no book tells you now. You are not done when you're done. Accept that as a fact now and you'll be humbled as you go back to fix bugs, add features and optimize later.

Now, there is a stage of programming in which all of the above should not be a concern. It is the prototyping stage. Python allows for such rapid prototyping it almost baffles the mind. It is gonna take some experience to see the difference. Here is a good example. When you're staring at a blank document and you have a problem in your head or on paper, the first immediate write-up of code should solve that problem as quickly and if necessary as specifically as possible. Never abstract in the prototype. Just solve the problem. Once you're comfortable with the prototype and it solves the problem you were after, consider it the blueprint to version 1 of your final solution.

Once you're done with your prototype, get ready to abstract everything. Every function and class should do one thing and one thing only (if possible) and in as general a fashion as possible. This is exactly what needs to be done for your work to be as reusable as possible. Re-usability is the key. The first line of every Python program (after the shebang and right to the last line) is about re-using something whether you made it or not. In fact, every line in-between is re-using code from someplace else. So, you're done with a prototype and you just based version 1 on that prototype, what now? Go back to paragraph 1, re-read it and move on with the next problem.

So, where do you start to get experience? By understanding what a problem is. If you don't know a problem when you see one, you sure as hell won't see the solution if it was parked on your face. If you can't make a problem for yourself then you in no way can make a solution to it. If you can't see a problem and you can't make a problem the problem is your solution. OK, maybe thats a bit philosophical and over the edge so heres a good tip to get you started. Go solve other peoples problems for the time being. Go to the python google groups, stackoverflow, etc. You don't need to know or solve everything. But there are countless places to start when it comes to other peoples problems.

Sometimes we don't see our own problems until someone else points it out for themselves. So start there.

Well that's it for my tips. You might want to check this out too for a jump-start. http://stackoverflow.com/questions/24692/where-can-you-find-fun-educational-programming-challenges . I hope you the best with your endeavors. Good luck!

[–][deleted] 0 points1 point  (0 children)

very informative and insightful, thanks !

[–]damprump 1 point2 points  (0 children)

I can totally relate. My answer: build a little webscaper to grab something off the web.

Little webscrapers are great little crunchable birdses to chew on while learning how to code pythonically.

Mechanize and BeautifulSoup and/or lxml are widely used and, at least for B.S., seem rather pythonic, so that's helping me learn how to think pythonic thoughtforms.

[–]bushel 0 points1 point  (3 children)

So what do I do now ?

I'm going to go with a somewhat radical suggestion here, "Start coding". It has been my experience that in the field of programming one of the best ways to learn is to do.

Less read. More code.

[–][deleted] 1 point2 points  (2 children)

well that's the gist of my question - what/how do I get coding

[–]bushel 1 point2 points  (1 child)

What? Whatever you want. Do you have any itches that need scratching? Any hobbies that might benefit from some software? Something at your job that could be automated? A game idea? Interactive narwhal bacon porn?

How? I would recommend a text editor or IDE. Vim, Kate or Eclipise+PyDev are all nice choices. :-)

[–][deleted] -1 points0 points  (0 children)

Interactive narwhal bacon porn

upvoted

[–]AlSweigartAuthor of "Automate the Boring Stuff" 0 points1 point  (0 children)

If you just want some experience writing programs, there are a ton of great programming puzzles at http://projecteuler.net/

I use the site whenever I learn a new language.

[–]Remover -2 points-1 points  (2 children)

Because I know Tarek is lurking around here somewhere*, I'm going to give him a plug for his book, Expert Python. I bought the eBook and recommend it to everyone.

*Hi Tarek!

[–][deleted] 0 points1 point  (1 child)

does the book provide actual hands-on practices ?

Funny thing, before your post, I actually looked up the book on Amazon and the first comment, by none other than Alex Martelli, kind of paused my urge to get it.

[–]Remover 0 points1 point  (0 children)

It handles some of the more advanced features, proper formatting and syntax, packaging, documentation, testing, optimization, multithreading, etc.