[issue26842] Python Tutorial 4.7.1: Need to explain default parameter lifetime

Raymond Hettinger report at bugs.python.org
Mon Apr 25 04:24:50 EDT 2016


Raymond Hettinger added the comment:

> I hope this is useful. I realize it is much longer than the original.

There lies the difficultly.  The purpose of the tutorial is to quickly introduce the language, not to take someone deeply down a rabbit hole.  The docs tend to be worded in an affirmative manner showing cases of the language being used properly, giving a brief warning where necessary.  Further explorations should be left as FAQs.  

I think we could add a FAQ link or somesuch to the existing warning but the main flow shouldn't be interrupted (many on the topics in the tutorial could warrant entire blog posts and scores of StackOverflow entries, but the tutorial itself aspires to be a "short and sweet" quick tour around the language.  

The utility and approachability of the tutorial would be undermined by overexpanding each new topic.  This is especially important in the early sections of the tutorial (i.e. section 4).  

Also, I don't really like the provided explanation, "there are two cases ...".  The actual execution model has one case (default arguments are evaluated once when the function is defined) and there are many ways to use it.

Lastly, this is only one facet of parameter specification and parameter passing.  Other facets include, variable length argument lists, keyword-only arguments, annotations, etc.   Any expanded coverage should occur later in the tutorial and cover all the facets collectively.

----------
nosy: +rhettinger
priority: normal -> low

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26842>
_______________________________________


More information about the Python-bugs-list mailing list