Skip to main content

Posts

Showing posts from February, 2007

Minimal Working Examples: How to, Why, and Who cares

When you have a problem and you rush to colleagues, or strangers on IRC and mailing lists, you've got to present a problem they'll want to help you fix, and with all the information they need to fix it. You can't give them information they dont need, because any extra work filing through your unrelated code is going to reduce the chances anyone will put in the time to help you. We can state a few rules about seeking help with code. Ask the question clearly and don't be ambiguous about your intentions and requirements. If you need to include code, it needs to include all important context. Present the problem without reference to out-of-context issues. Don't come in with a link to your entire body of code telling us it doesn't work. What doesn't work is asking for help like that. Besides telling us exactly how things don't work, and what they are doing compared to what you are expecting, you need to give us code that specifically and only demonstrates the

Standard Gems: colorsys

Lots of us do color work. Maybe you're writing a full-fledged Photoshop killer, or you just want a utility to do some bulk conversions or color scheme generations. Well, in any case, you might find the often-forgotten colorsys module handy. You can easily convert between different color component systems with these included functions: hls_to_rgb(h, l, s) hsv_to_rgb(h, s, v) rgb_to_hls(r, g, b) rgb_to_hsv(r, g, b) rgb_to_yiq(r, g, b) yiq_to_rgb(y, i, q)

Book Review: Practices of an Agile Developer

Software development is widely known as having the largest gap of any discipline between the best known practices and the actual practices utilized in the field. The most depressing part of that statement is how inaccurate the qualifier of "widely known" probably is, because if the gap was as well and widely known as it should be, the gap would be shrinking much faster than it is. Is the gap even shrinking at all? One of the things on the good end of this gap is the collective practices known as Agile Development. The creation of software is fluid and must be adaptable at a moments notice, defined as it is created, and grown rather than built, says the mantras of the agile development proponents. They contrast to the traditional and aging mentality of designing everything before writing anything, following a walled path to the goal, and building monoliths of code. The differences between the old side and the new side are great, and this is the gap we need to wade across to so

RTFM Not Just a Disgruntled Reply

Are you or have you been new to something technical? Of course. Have you asked a question when you were lost? Have you been told, by those who you trusted to enlighten your path, "RTFM!"? Well, you are not alone, and if you felt you got a raw deal, you are not alone. However, you are wrong. "RTFM" is a perfectly valid and, despite the opinion of many, very good advice in your time of need, indeed. The camp of the knowledge seekers is seperated into two groups, with the line between them varying depending on the context. The first and largest group is the active knowledge seeker, who is after some bit of information. The second and smaller group are those who have that information. The seeking group has two options to get what they need: utilizing known resources, such as books and articles and tutorials; or, asking those who have previously sought and found, and can give them the information they seek quickly, without wading through entire volumes of documentation.

Pure Functions in the Python Standard Library?

I am toying with a small package for working with and developing pure functions in Python. An important part of this is allowing the pure functions you write to use as much of the standard library as possible, while remaining pure. What functions in the standard library could you call pure? Builtin types, the entire math library, the itertools module, etc. are on my list, but I don't want to miss things. Any suggestions? So far I have a decorator that ensures a function A) only takes immutables and known-pure functions as arguments, and B) ensures any global names used within the function are pure functions. It is primitive, but a start. I hope to take this further with some actual uses, such as create working processes locally and remotely and pushing pure functions to them. This also has interesting potential for optimizing large computations, like executing functions before they are called when the potential arguments are known. Pure functions are interesting and might be a nice

PyCon Recordings?

Is anyone planning on handling the recording and posting of talks at PyCon '08? I can't make it, yet again, and I really hope the talks can be available to the non-attenders this year. YouTube would take them kindly, as well (wink wink).

Standard Gems: shlex.split()

str.split() is so well known, but a simple step beyond leaves a lot of pythonistas lost: how do you split without breaking up embedded strings? How do you split "1 '2 3' 4" into ['1', '2 3', '4']? Why, shlex.split("1 '2 3' 4"), of course! The shlex module is a lexical analyzer and includes this little useful utility for us.

Standard Gems: calendar.month_name

This is part of a new series I want to keep up with. There are a lot of hidden gems in the Python standard library, which gets larger all the time. As the number of packages and modules grow, and the size of those grow themselves, it becomes harder and harder for all of us to keep everything in mind all the time. There are large parts of the standard library I have never used or even looked at once, because its never been needed by anything I have done. This means that when I do have a need for these things, I don't know they exist. Perhaps one of the greatest reasons for reinventing the wheel is simply ignorance of the wheel existing in the first place! I see the same problem in others all the time. This series, "Standard Gems", is an attempt to get things out there that some people maybe have not seen or known of, and will later find useful when the need sparks memory of the gem. If you have any suggestions for gems, please drop me a line ! calendar.month_name Ever need
Extreme Code - Version Control For One File You should start using version control systems when you only have a single file. You don't need a version control system until you have a large project and lots of collaborators. Two statements I've heard from individuals of great caliber, and it carried weight coming from individuals on both sides. Version control is important, and no developer worth their weight in USB keys will tell you to never user a VCS, but exactly when and where and why you should use them is not so agreed upon. The differences in opinion come from cultural, experience, and industry reasons. Many members of the free software community seem more exposed and ready to use CVS or Subversion, where version control is almost impossible to avoid when you need to collaborate across the world. Some individuals have horror stories about projects without version control, and others have never seen practical benefit in their time as developers. Yet, some simply work i

Extreme Code - Examining Software Development Through Polarized Eyes

Developers are opinionated people. There are issues in our line of work with very bold lines between one side and the next, arguing over this point and that. I will not debate if emacs or vim is the superior editor, but I'm going to take a look at some important issues from the extreme lines, from the far polarized groups that chant all-or-nothing for their answer, from the points of view where the distractions of opposition won't lead us astray. This is not to say I agree with either side, as I will try to look at them both, separately, but that I think looking at some issues, temporarily, in with a few doors shut is a good way to get the full view of that aspect. I'll be sure to disclose my personal preferences, but I want to be as neutral in the matters as I can be. This series will be called "Extreme Code" because of the "extreme" views we'll examine on each of the issues. The first edition will be published tomorrow, and is entitled "Extrem