3 ms·
I know this is a little nitpicky, but your Python example has way more brackets than are strictly necessary. if post.created_at < datetime.now() - timedelt
by robbles 13y ago
I know this is a little nitpicky, but your Python example has way more brackets than are strictly necessary.
if post.created_at < datetime.now() - timedelta(minutes=5):
I agree with your argument in principle though. Just wanted to point out if you're trying to make a point about readability / ease of use with code examples, you should try as hard as possible to make each example optimized to avoid accidentally creating a straw man.
Also, one criticism of the Ruby version is the invisibility of the types involved. What type is returned by 5.minutes vs 5.minutes.ago? How do I know I can compare the second to a date attribute from ActiveRecord? The Python version is more verbose, but I think it's more clear that I'm using two datetime's and a timedelta.
- jshen 13y agoIn both cases you have to either remember a lot of details, play with it in the reply, or look at the docs as you are writing it. Once it is written the ruby code is far easier to read.