> You know Steve, as I was typing the beginning of a reply responding to > a similar question you asked earlier in your response, I suddenly > realized how ridiculous having a parameter of 'col/2' is! I'll just > have either eat crow or attribute this to a brain fart. You pick!
Just to play devil's advocate: it's not crazy. Essentially, what you're asking for is called "pattern matching", and it is done in a class of many programming languages. One of the more well known of these is Prolog. https://en.wikipedia.org/wiki/Prolog. Other forms of pattern matching show up in ML, and it *is* used in industry. (e.g. Microsoft's F#.) It's a bit out of scope to talk about this much here, but I just wanted to chime in here to say that you are not ridiculous. :P But Python does not have a robust pattern matching facility; the closest it has is a limited form of tuple matching: ###################### > def f((x,y), z): ... print x, y, z ... > f([1, 2], 3) 1 2 3 ###################### with very limited applicability and rarely used. I hope everyone is well! _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor