Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Advanced Objects Constructicons

(books = None) explanation

So a few times when we create args in a method, we put them equal to None. Can someone explain what this does in more detail?

1 Answer

Ryan Cross
Ryan Cross
5,742 Points

python doesnt like a mutable parameter. you want an empty list to work with so what about books = [] as a parameter? it doesnt work. read this for why:

http://docs.python-guide.org/en/latest/writing/gotchas/

Ryan, thanks for the info! I was puzzled by exactly the same question, and wondered why I just couldn't pass an empty list in as the parameter (instead of None). I have bookmarked that link! :-)

Cheers, Eric