Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


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? :-)


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.


It's also covered in the official Python tutorial.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: