exception handling in complex Python programs
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed Aug 20 14:57:40 EDT 2008
On Wed, 20 Aug 2008 18:37:02 +0200, Bruno Desthuilliers wrote:
>> I personally think this is sloppy because you have to couple the
>> exception type with the function --- between file() and open() in
>> Python 2 and 3, a NameError is thrown with open() in Python 3
>
> ??? I suspect this has nothing to do with any error happening while
> opening the file. NameError means the name doesn't exists in the current
> namespace nor it's enclosing namespaces. Could it be possible that
> open() has been removed from Py3k ?
No it's moved/changed but there's still a name for it in the builtin
namespace. `file` on the other hand is gone:
Python 3.0b2 (r30b2:65080, Aug 20 2008, 20:41:17)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> open
<class 'io.OpenWrapper'>
>>> file
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'file' is not defined
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list