[Chicago] Factoring fun with functions in Python

Carl Karsten carl at personnelware.com
Fri Nov 16 17:20:15 CET 2012

On Fri, Nov 16, 2012 at 9:25 AM, Garrett Smith <g at rre.tt> 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.
> The premise is that *functions* are used to represent logic.
> "db.cursor()" is a method invocation on an object, not a function. If
> you concede that "getting a cursor" is an important logical operation
> in the program, according to the rules of the text-playing-game, it
> must be represented by a function.


In the calling code, db.cursor() and get_cursor(db) are the same.
What they do/return/affect can be the same, and there is no reason one
syntax/notation should imply some different behavior.      Assuming
the syntax of the language supports it, both can be decorated, both
can be passed as a parameter.

I think the db.cursor syntax has the advantage of what can be done
inside the definition: the oop code can call it's parent
implementation using


Given that just passes some parameters to some other wad of code you
can implement the same thing as a function - you don't need opp.   oop
gives us the luxury of super() keeping track of the parent.  This
luxury imposes some consistent organization, which is a good thing.
It is kind of like name spaces, maybe it is just that.  What is/isn't
a name space doesn't really matter if they are both keeping things
organized and easy to follow.

Carl K

More information about the Chicago mailing list