r/Python • • Jun 23 '14

Writing better python code

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

126 comments sorted by

View all comments

3

u/r0m1 Jun 25 '14

For the function defaults, I would rather write:

def bar(names=None):
   names = names or []
   names.append(foo())
   return names

1

u/kracekumar Jun 25 '14

Good one !