classification
Title: NameError in tutorial/interpreter
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: docs@python, eric.araujo, ezio.melotti, georg.brandl, orsenthil, r.david.murray
Priority: normal Keywords: needs review, patch

Created on 2010-11-28 05:48 by eric.araujo, last changed 2010-12-17 16:12 by r.david.murray. 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
2010-12-17 16:12:21r.david.murraysetstatus: open -> closed
nosy: georg.brandl, orsenthil, ezio.melotti, eric.araujo, r.david.murray, docs@python
messages: + msg124224

resolution: fixed
stage: patch review -> resolved
2010-12-17 16:09:18r.david.murraysetfiles: + tut_argv.diff
nosy: georg.brandl, orsenthil, ezio.melotti, eric.araujo, r.david.murray, docs@python
2010-12-17 16:09:00r.david.murraysetfiles: - tut_argv.diff
nosy: georg.brandl, orsenthil, ezio.melotti, eric.araujo, r.david.murray, docs@python
2010-12-17 16:07:28georg.brandlsetnosy: georg.brandl, orsenthil, ezio.melotti, eric.araujo, r.david.murray, docs@python
messages: + msg124223
2010-12-17 16:06:23r.david.murraysetfiles: + tut_argv.diff
nosy: + r.david.murray
messages: + msg124222

2010-12-17 15:51:39georg.brandlsetnosy: + georg.brandl
messages: + msg124217
2010-12-16 01:21:11eric.araujosetnosy: orsenthil, ezio.melotti, eric.araujo, docs@python
messages: + msg124100
2010-11-29 14:12:13eric.araujosetmessages: + msg122803
2010-11-29 08:58:29orsenthilsetnosy: + orsenthil
messages: + msg122783
2010-11-28 06:03:43ezio.melottisetnosy: + ezio.melotti
messages: + msg122636
2010-11-28 05:48:29eric.araujosetnosy: + docs@python
2010-11-28 05:48:16eric.araujocreate