From: Brendan B. <bre...@br...> - 2015-04-23 17:17:06
|
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 |