Issue 10559: NameError in tutorial/interpreter (original) (raw)

Created on 2010-11-28 05:48 by eric.araujo, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tut_argv.diff r.david.murray,2010-12-17 16:09
Messages (9)
msg122635 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-28 05:48
From the docs@ mailing list: “Tutorial 2.1.1: name 'sys' is not defined When the student tells python to evaluate sys.argv[0] as described, she gets the following error: name 'sys' is not defined” Imports have not been introduced yet, so I propose this simple change: -left in ``sys.argv`` for the command or module to handle. +left in ``sys.argv`` for the command or module to handle. You need to +execute ``import sys`` before you can reference ``sys.argv``. I’m not committing directly because I’d like feedback: Is the wording okay for the beginning of the tutorial?
msg122636 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-11-28 06:03
What about "In order to use ``sys.argv`` you have to import the :mod:`sys` module doing ``import sys``.". "reference" sounds weird to me, and imho saying "import the module" is ok even if imports have not been introduced yet. If the user doesn't understand what "importing a module" means he can just execute the command as is.
msg122783 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-11-29 08:58
On Sun, Nov 28, 2010 at 05:48:20AM +0000, Éric Araujo wrote: > I’m not committing directly because I’d like feedback: Is the > wording okay for the beginning of the tutorial? It seems fine and useful. Please go ahead.
msg122803 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-29 14:12
What about: “You need to execute ``import sys`` before you can use ``sys.argv``.”
msg124100 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-12-16 01:21
New wording: When known to the interpreter, the script name and additional arguments thereafter are passed to the script in the variable ``sys.argv``, which is a -list of strings. Its length is at least one; when no script and no arguments +list of strings. You have to execute ``import sys`` before you can use that +list. Its length is at least one; when no script and no arguments are given, ``sys.argv[0]`` is an empty string. When the script name is given as ``'-'`` (meaning standard input), ``sys.argv[0]`` is set to ``'-'``. When :option:`-c` *command* is used, ``sys.argv[0]`` is set to ``'-c'``. When
msg124217 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-12-17 15:51
"Use that list" doesn't make me happy, what about "access"?
msg124222 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-17 16:06
Attached diff provides another suggested rewording that I think is clearer.
msg124223 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-12-17 16:07
+1.
msg124224 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-17 16:12
Committed in r87337.
History
Date User Action Args
2022-04-11 14:57:09 admin set github: 54768
2010-12-17 16:12:21 r.david.murray set status: open -> closednosy:georg.brandl, orsenthil, ezio.melotti, eric.araujo, r.david.murray, docs@pythonmessages: + resolution: fixedstage: patch review -> resolved
2010-12-17 16:09:18 r.david.murray set files: + tut_argv.diffnosy:georg.brandl, orsenthil, ezio.melotti, eric.araujo, r.david.murray, docs@python
2010-12-17 16:09:00 r.david.murray set files: - tut_argv.diffnosy:georg.brandl, orsenthil, ezio.melotti, eric.araujo, r.david.murray, docs@python
2010-12-17 16:07:28 georg.brandl set nosy:georg.brandl, orsenthil, ezio.melotti, eric.araujo, r.david.murray, docs@pythonmessages: +
2010-12-17 16:06:23 r.david.murray set files: + tut_argv.diffnosy: + r.david.murraymessages: +
2010-12-17 15:51:39 georg.brandl set nosy: + georg.brandlmessages: +
2010-12-16 01:21:11 eric.araujo set nosy:orsenthil, ezio.melotti, eric.araujo, docs@pythonmessages: +
2010-11-29 14:12:13 eric.araujo set messages: +
2010-11-29 08:58:29 orsenthil set nosy: + orsenthilmessages: +
2010-11-28 06:03:43 ezio.melotti set nosy: + ezio.melottimessages: +
2010-11-28 05:48:29 eric.araujo set nosy: + docs@python
2010-11-28 05:48:16 eric.araujo create