New submission from cate c...@debian.org:
http://docs.python.org/dev/howto/doanddont.html use twice in example the
opne function, which should be written as open. From google it seems
that also 3.x is affected (but not really checked)
--
assignee: georg.brandl
components: Documentation
John Szakmeister j...@szakmeister.net added the comment:
Here's a patch for trunk.
--
keywords: +patch
nosy: +jszakmeister
Added file: http://bugs.python.org/file14203/issue-6220-doanddont.patch
___
Python tracker rep...@bugs.python.org
Ezio Melotti ezio.melo...@gmail.com added the comment:
That typo is intentional, it's also written in the comment:
try:
foo = opne(file) # misspelled open
except:
sys.exit(could not open file!)
This example shows how a bare except will catch the NameError caused by
'opne' and return the
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6220
___
___
John Szakmeister j...@szakmeister.net added the comment:
That'll teach me to pay more attention before submitting a patch.
Thanks Ezio!
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6220
John Szakmeister j...@szakmeister.net added the comment:
Actually, what's the second example trying to show:
try:
foo = opne(file) # will be changed to open as soon as we run it
except IOError:
sys.exit(could not open file)
I'm not sure what that comment really means?
--
Ezio Melotti ezio.melo...@gmail.com added the comment:
If we use the bare except: the message could not open file! is shown
and we would waste time trying to figure out why it can't be opened.
Instead, if we use except IOError:, the first time we run the program
the error NameError: name 'opne'