[Chicago] Factoring fun with functions in Python
Garrett Smith
g at rre.tt
Sun Nov 18 01:53:10 CET 2012
On Sat, Nov 17, 2012 at 3:37 PM, Martin Maney <maney at two14.net> wrote:
> On Fri, Nov 16, 2012 at 09:25:10AM -0600, Garrett Smith wrote:
>> Let's be clear, the whole point of the exercise is to play with text.
>> Whether it's pointless shuffling depends on what you're trying to
>> accomplish.
>
> Ah, so then there's little to be said, since I don't see any point in
> avoiding constructs that are painfully bad in Erlang when writing code
> in Python. Which is not at all the same as saying FP has nothing to
> teach us, but that's a whole lot different than just aping the form of
> it (and if the latter isn't a Cargo Cult activity, what is?).
>
>> "db.cursor()" is a method invocation on an object, not a function.
>
> cursor = MySQLdb.cursor # this can't work, it's not a function.
>
> ...
>
> cur = cursor(db) # ROFL when it does
I'm afraid you've lost me.
>> If you want to be proper annoyed, read the big brother to the OP :)
>
> Actually, I think that was the problem: you seemed to make sense in
> Erlang (I read both before I first tried to express what bothered me
> about the Python version) so I was expecting something equally sensible
> - a useful, analogous treatment in Python, to suit the very different
> languages. As the old saw has it, you can write FORTRAN in pretty much
> any language. But why do such a thing?
The premise isn't "here's what the cool kids are using, take it Python!"
It's this: convert important operations that are hidden in blocks of
code to functions.
You don't like the idea of converting a single line of code (still a
block) into a function because it's pointless text shuffling. So
don't. But surely you're not objecting to the idea that functions can
be used to formally define the logical operations of your program?
Or are you under the impression that this is merely a style-of-the-day
and we should get back to the canon of Good Programming, which is what
exactly?
Garrett
More information about the Chicago
mailing list