November 11, 2016

Why Python and Django, you ask?

Why Python and Django, you ask?

Well. Python doesn't necessarily make coding awesome, but gives you the tools to write awesome code. Which feels awesome. You can find a quick and easy demonstration of what Pythonic/Djangonic code can feel like here:

send_to = list()

for friend_id in users:
  try:
    friend = User.objects.get(pk=friend_id)
  except User.DoesNotExist:
    continue
  
  if friend.push_notification_token:
    send_to.append((friend.pk, friend.apn_token))

OR

send_to = [(f.pk, f.apn_token) for f in User.objects.get(pk__in=users, apn_token__isnull=False)]

Feels good! So much productive. Wow.

A good read with examples on what 'Pythonic' is, can be found here: http://blog.startifact.com/posts/older/what-is-pythonic.html, written by Martijn Faassen.