Confessions of a Python fanboy

alex23 wuwei23 at
Thu Jul 30 06:04:27 CEST 2009

On Jul 30, 1:06 pm, r <rt8... at> wrote:
> 1.) No need to use "()" to call a function with no arguments.
> Python --> "obj.m2().m3()" --ugly
>   Ruby --> "obj.m1.m2.m3"  -- sweeet!
> Man, i must admit i really like this, and your code will look so much
> cleaner.

How do you distinguish between calling a method with no arguments, and
getting access to the method object itself (because it _is_ an object,
y'know, it's OO all the way down...)?

> 2.) the .each method
> container.each{|localVar| block}
> This method can really cleanup some ugly for loops, although i really
> like the readability of for loops.

map(lambda localVar: <block>, sequence)


def usefully_named_func(var):
    return var

transformed = [usefully_named_func(v) for v in sequence]

> 3.) true OOP
> Now before you go and get all "huffy" over this statement, hear me
> out. Python is the best language in the world. But it damn sure has
> some warts! "len(this)" instead of "obj.length" max(that) instead of
> [1,2,3,4,5].max().

As the Zen says: '[P]racticality beats purity'. Personally, I'm not
sure how a handful of convenient built-in functions make a language in
which _everything is an object_ somehow "false" OO.

If you're really that concerned with writing "true" OO (for some
wildly variable value of "true"), there's nothing stopping you from
doing so now:


With max(), this is a built-in that takes _any_ iterable and an
optional key function, and returns the highest value as per the key.
This means that _every_ iterable object - as _well_ as every object
that supports enough of the iterator protocol - can be handed to max()
and a result obtained. So at best, I just need to make sure my new
sequence-type provides the iterator protocol and viola, it works with
max() without me having to hand-code a .max() that's specialised for
my new type, and without Python forcing me to have a complex
inheritance chain just to make sure I include the right
MaxableSequence ancestor to inherit the right .max().

> PS stay tuned for more from this series....

Is this going to be more of you telling us - without any apparent
irony whatsoever - how Ruby has some valid points after all your
vilification last year when we said the same to you?  If so, where can
I sign up?!

(You should consider trading guest spot posts with Xah Lee on your
respective blogs. You both have a very similar approach to programming
& programming languages and I think the synergy would be amazing to

More information about the Python-list mailing list