3 ms·
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
by Mikeb85 5y 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.
- iterati 5y agoPython is a multi-paradigm language, of which OO is one paradigm it supports.
- Mikeb85 5y agoRuby 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?
- jimbokun 5y agoRuby is a strongly OO language, which arguably also has better support for functional programming than Python.
- cutler 5y agoYes, that's the Zen of Ruby and why I love it.
- cutler 5y agoNot 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.
- knodi123 5y ago> 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'
- cle 5y agoI've always assumed this was to maintain syntactic consistency with comprehensions like [x for x in arr if x > 2].