Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Why would you not just use a list argument instead of using *args? What is the benefit of using *args?

What usecases are there where using *args is better than requesting or expecting a list parameter?

2 Answers

Steven Parker
Steven Parker
215,954 Points

Packing comes in handy when you are implementing or modifying an interface that is already designed to take multiple arguments, or you are creating something new and want to provide a more compact calling sequence for the user.

So the benefit is just readability? By "provide a more compact calling sequence", I assume you mean that *args allows the user to just create the variables inline rather than having to create a list first and then pass that into the method call

Movies('Titanic', 'Inception')


movies = ['Titanic', 'Inception'] Movies(movies)

Steven Parker
Steven Parker
215,954 Points

Or,   Movies('Titanic', 'Inception')   vs.   Movies(['Titanic', 'Inception']) :point_left: extra brackets.

Hope that helped. You can mark the question solved by choosing a "best answer".
And happy coding!