Around this time last year I posted a cheatsheet for writing/packaging/testing scripts in python. I updated that since I'm speaking this week at the Utah Open Source Conference and will be giving an introductory talk about python. I've also been given my brother's permission to re-hash his Pycon presentation about Lasers, Webcams and Halloween Games.
For my intro talk, I've created an Intro to Python cheatsheet, and I've updated my packaging/testing/writing scripts in python cheatsheet. The cheatsheets are actually a tarball .png files. Props to the docutils, pygments, inkscape, and OOo folks.
For the curious, here's the process of creating the sheets. Both of these cheatsheets were started as code, both have tests. I then used pygments to output to formatted/colored svg. Inkscape was used to layout, format and markup the sheets in a landscape oriented US Letter sized page. Sadly the pdf export of the current inkscape doesn't make pretty pdfs (note to self, file a bug). So I end up exporting 300 dpi pngs. I also tried creating pdfs in OOo, but alas, kpdf screws up printing of said pdfs. Printing from OOo works fine.
Feedback is welcome. I'm interested in knowing if these are useful, since I've got the begginings of a guppy/heapy one, as well as the pyexcelerator one I posted about a bit back. The svg for the script cheatsheet uses layers, and I started adding some diagonal comments that I thought would be useful. If people want the svgs or source files let me know.
update It seems that some people believe these to be a waste of time. Perhaps. I'm a visual/dead tree person. If I have a good reference, I'll often use that before a search engine. I mark and annotate my reference books, and I know where I can find stuff that I don't want to keep in my brain. Admittedly the Intro cheatsheet is very basic, and it's meant to go with my presentation to teach python to people who know how to program. It doesn't enumerate all methods on lists or dictionaries, but my presentation teaches how to find those quickly. And it is a "cheatsheet" in that my presentation is "hands on", so people will be programming during it, not just listening to some biased person espousing the virtues of their pet programming language. If it is useful to others, great! The script cheatsheet actually has a bunch of best practices (or at least I believe them to be) that aren't well known or used(or people are too lazy to use), or that the documentation is hard to find or annoying. I've seen many a poorly written python script....
You should give links to the SVG files because Firefox has no problem
displaying SVG right in the browser. BTW, they look good!
I would recommendation putting a variety of objects into your list and
dictionary examples to show that a lists, dictionaries, and tuples store
*objects*. For example, I would add:
That's a handy reference. Maybe dir() and help() examples could be a little
more clear?
>>> dir(animal) #since "animal" and "add" were used earlier in the sheet >>> help(add) or >>> help(str.split) #str instead of ""Looks like a great reference for starting out in python! I'll pass it along to some who might be interested.
I loved these, especially for the way they convey conventions. I've worked
in Python for two years now, but it's all been on one major project, plus
personal 100 liners. So I have a good understanding of the language and
libraries, but a relatively shaky sense of common conventions used on
Python projects, such as using a version attribute to store that
information. Now I'm all excited to read about some of the things I see on
your cheatsheet and adopt them on my current personal projects.