Skip to content

Instantly share code, notes, and snippets.

@sloria
Last active December 19, 2015 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sloria/5895717 to your computer and use it in GitHub Desktop.
Save sloria/5895717 to your computer and use it in GitHub Desktop.
# Bad
if type(entry) is Film:
responsible = entry.producer
else:
responsible = entry.author
# Shouldn't use type() or isinstance() in conditional --> smelly
# Better
class Film:
...
@property
def responsible(self):
return self.producer
entry.responsible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment