Hacker News new | ask | show | jobs
by Mikeb85 1622 days ago
Ok, that's a nicer result (obviously I don't write Python lol) but still seems inconsistent to me (putting the function before the array) considering Python is an OO language and most people are going to be writing methods for classes where you call methods with dot. I just remember list comprehensions from Coffee-script and not going to lie, I hate them. It's like reading backwards.
2 comments

> still seems inconsistent to me (putting the function before the array)

I'm experienced in ruby, and learning python for a project. I don't think I'll ever not wince when using python's ternary;

ruby: size = (waist > 30) ? 'large' : 'small'

python: size = 'large' if (waist > 30) else 'small'

I've always assumed this was to maintain syntactic consistency with comprehensions like [x for x in arr if x > 2].
Python is a multi-paradigm language, of which OO is one paradigm it supports.
Ruby has map, filter, reduce and a bunch of other functional methods. It's more about the consistency of wondering what's a function versus what's a method and then things like list comprehensions and for loops. Python also doesn't have a lot of the goodies of a real functional language, it encourages for loops and seems to be even more procedural than Ruby but less OO?
Not really. Python 3 is all OO under the hood including what appear to be procedural functions. It's just not as elegant as Ruby's OO.
Ruby is a strongly OO language, which arguably also has better support for functional programming than Python.
Yes, that's the Zen of Ruby and why I love it.