Brendan, good catch, I didn't notice Virgil's confusion earlier. I think
that is a good explanation. I remember getting very confused by all of that
stuff back when I started in Python. I think mostly because I don't know of
any other language that does argument handling like how Python does it. I
learned it all by "school-of-hard-knocks". Does anybody recommend a really
good online reference that explains the ins-and-outs of positional and
keyword arguments for newbies?

Cheers!
Ben Root


On Thu, Apr 23, 2015 at 1:00 PM, Brendan Barnwell <brenb...@brenbarn.net>
wrote:

> On 2015-04-23 03:22, Virgil Stokes wrote:
> >
> > 1. There are 3 positional arguments given for animation.FuncAnimation;
> > but, in the
> > API documentation for this class
> > (http://matplotlib.org/api/animation_api.html), only
> > two positional arguments are shown.
>
>         One thing I think may be misleading you is that you seem to be
> misunderstanding how positional and keyword arguments work in Python.
> Specifying a default value for an argument in a function definition
> doesn't mean that you can *only* pass it by keyword when you call it.
> Any named argument can always be passed positionally or by keyword (in
> Python 2).  For instance, if I define a function like this:
>
> def foo(a, b=2):
>      print a+b
>
> I can still call it like this:
>
> foo(8, 10)
>
> I can even call it like this (passing both arguments as keywords "out of
> order")
>
> foo(b=10, a=8)
>
>         Writing "b=2" in the function definition doesn't so much "make b a
> keyword argument" as just "specify a default value for b".  So in the
> FuncAnimation documentation you mentioned, "frames" is not required to
> be a keyword argument, and can still be passed positionally.  (In Python
> 3 there are keyword-only arguments, and even in Python 2 the variadic
> **kwargs syntax collects only keyword arguments, but those aren't
> involved as far as the "frame" argument here is concerned.)
>
> --
> Brendan Barnwell
> "Do not follow where the path may lead.  Go, instead, where there is no
> path, and leave a trail."
>     --author unknown
>
>
> ------------------------------------------------------------------------------
> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> Develop your own process in accordance with the BPMN 2 standard
> Learn Process modeling best practices with Bonita BPM through live
> exercises
> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
> event?utm_
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to