r/Python • • Jun 23 '14

Writing better python code

https://gist.github.com/kracekumar/09a60ec75a4de19b346e
143 Upvotes

126 comments sorted by

View all comments

0

u/[deleted] Jun 23 '14

[deleted]

3

u/cdcformatc Jun 23 '14

I object to if super_users: over if len(super_users) > 0: There is a huge difference between an empty list and None. If you want to check that the length of the list is greater than zero you should... just do that.

A lot of this reads like "Abuse syntax to make your code look more Pythonic" and treats Pythonic like some lofty goal. A lot of "Pythonic" code is just harder to read, it isn't an end in itself.

1

u/turtle_with_dentures Jun 23 '14

Thank you. Ran in to this exact issue earlier when a JSON request was returning an empty list.