Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I memorize the order of function arguments when learning a new module?

For example, I am now learning wxPython, specifically a class' init function:

__init__(self, parent, id=-1, label=EmptyString, pos=DefaultPosition,
 size=DefaultSize, style=0, name=StaticTextNameStr) 

As a matter of good programming practice, should I memorize the order of the parameters, or just the keywords and call the function using the keywords everytime? Is it better to do the latter for readability?

like image 448
talloaktrees Avatar asked Feb 18 '12 05:02

talloaktrees


1 Answers

Memorize? No. That's what the documentation (including source code) is there for.

That being said, sometimes using keyword arguments helps the code clarity, particularly for functions which take a large number of parameters. And you should always strive to write clear code, especially in Python where the source code is meant to supplement the documentation.

like image 77
David Z Avatar answered Oct 05 '22 06:10

David Z