News for hackers. Stuff that matters.
Re:Understanding python *args and **kwargs by TommyWiseau on Friday October 02, 2009 @11:47AM (#857285)
Jesus, does this really require such a long article? Just open the interpreter and check it out. Took me 5 minutes when I decided to figure it out.
Re:Understanding python *args and **kwargs by plinkplonk on Friday October 02, 2009 @01:00PM (#857445)
The number of upvotes such a content-lite article gets on HN is interesting, and maybe an indicator of a changing demographic here.

What's next? a few pages on Ruby's method_missing? :-)

Re:Understanding python *args and **kwargs by algorias on Friday October 02, 2009 @12:39PM (#857389)
5 minutes followed by a sweet aha! moment.

What the article seems to miss, though (only skimmed it), is that you need to be incredibly careful with taking kwargs, specially if you're passing them along into secondary functions within the called function. Hidden bugs lie that way, as you could end up with bad/misspelled args that you think are having an effect, but aren't.

Always make sure all kwargs get unpacked.

Re:Understanding python *args and **kwargs by ubernostrum on Friday October 02, 2009 @12:52PM (#857422)
It's also covered in the official Python tutorial.
Re:Understanding python *args and **kwargs by drawkbox on Friday October 02, 2009 @03:37PM (#857828)
No kidding.

  A much, much more simple way to put it is 
  anything *args is a list, anything  **kwargs is 
  a dictionary.

  The * simply means list (set). 
  ** simply means dictionary (name/value pairs)

  * and ** has a much different meaning in other 
  languages as parameters.

  * args is very similar to ... in other languages 
  that let you send n arguments.