TheAlice 3D project developed a 3D programming environment for beginners. Originally, they usedPython but later switched to another language. Two Python-specific issues were found to be problematic for beginners: (1) the case-sensitivity of the language ("variable1" is not the same as "Variable1"), and (2) integer division (a carryover from the programming language C, 3 / 4 = 0, not 0.75, because the division of integers returns integers). Python 3 changed the latter by introducing an explicit integer division operator, so now 3 / 4 is 0.75 and 3 // 4 = 0. The former is just part of the language. Seeinterview in Linux Journal and thisdissertation for more details.
Changing lists during iteration. A common example is to loop over a list to check an entry for some condition, which, if met, leads to deleting the entry. This will mess up the iteration. To do this safely, iterate over a copy. With Python 3, this can also happen with dicts, since thekeys,values anditems method of a dict, often used to generate something to iterate over, actually produce views into the dict, and thus are subject to change if the dict changes.
Widely known as the "No Module named..." error, this is an issue all programmers face at some point (sometimes multiple times). This article(The "No Module Named" Error) addresses this issue, going through every possible scenario in which this error occurs and how to avoid running into it again.
Subtle errors--which may cause some fairly difficult to follow messages--happen when built-in type and function names are "shadowed" (i.e., redefined). For example, usingstr as a variable name in a scope (i.e., a function or class) will prevent the built-in function of the same name from being usable, producing an error like this:TypeError: 'str' object is not callable
Even for advanced users there are features of the Python language that can cause difficulties. SeePythonWarts for resources and observations on such matters. These observations have in part been used to suggest refinements in future Python versions.
SomeIntermediate Conundrums have been noted with regard to the behavior of some Python features, although these may be outside the scope of beginner problems.
ThePyChecker module can alert users to many common errors. There also is a tool calledPyLint.
To see languages that have been used successfully with beginners and children, see Logo,HyperTalk (used inHyperCard andSuperCard), HTML,JavaScript, variants of Basic, etc.
This page was moved from the educational wikis atcoedit.net to here.
BeginnerErrorsWithPythonProgramming (last edited 2021-01-31 19:34:47 byMatsWichmann)
Unable to edit the page? See the FrontPage for instructions.