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

Whats the difference between args and kwargs, why args before kwargs, and can I see an example of both in use

Whats the difference between args and kwargs, is kwargs for use with dictionaries and args for use with list/tuples.

Why must we list args before kwargs

When would we use both together in the same function can anyone think of an example

2 Answers

Honestly, unless you're writing framework code, decorators or heavy OOP, you may not use them much. Here's a good example https://stackoverflow.com/a/1415882/3182843. It sort of boils down to whether or not you're just passing (any) arguments along or are unsure of the function's signature depending on the caller.

If you're just getting started, it's basically irrelevant. Learn how to write clear, interpretable functions with defined arguments