no module named exceptions?

J

Joaquin Abian

In python 3.1,
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import exceptions
ImportError: No module named exceptions

in 2.6 no exception is raised
It should be the same in 3.1, isnt it?

Joaquin
 
C

Chris Rebert

This is what he is expecting. Importing exceptions works fine in 2.6.4, not
so
in python 3.1.
Python 2.6.4 (r264:75706, Nov  3 2009, 18:12:54)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

It appears to have been removed between Python 3.1.2
(http://docs.python.org/py3k/modindex.html#cap-E) and Python 3.2a0
(http://docs.python.org/dev/py3k/modindex.html#cap-E). Exactly why, I
don't know. I wasn't able to locate anything about it in a quick scan
of the Python 3000 PEPs.

Cheers,
Chris
 
G

Gary Herron

Joaquin said:
In python 3.1,


Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import exceptions
ImportError: No module named exceptions

in 2.6 no exception is raised
It should be the same in 3.1, isnt it?

Joaquin

In 2.x, the exceptions module was imported automatically, so there was
never a need to explicitly import it.
For example:
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.<type 'exceptions.ImportError'>


In Python 3.x, it appears the same effect is achieved by putting the
Exceptions in the builtin module
For example:
Python 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.<class 'ImportError'>

And another example:<class 'ImportError'>
 
N

Ned Deily

Chris Rebert said:
This is what he is expecting. Importing exceptions works fine in 2.6.4, not
so
in python 3.1.
Python 2.6.4 (r264:75706, Nov  3 2009, 18:12:54)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import exceptions

It appears to have been removed between Python 3.1.2
(http://docs.python.org/py3k/modindex.html#cap-E) and Python 3.2a0
(http://docs.python.org/dev/py3k/modindex.html#cap-E). Exactly why, I
don't know. I wasn't able to locate anything about it in a quick scan
of the Python 3000 PEPs.

The exceptions module doesn't exist in Python 3 but the documentation
had not been cleaned up until recently:

http://bugs.python.org/issue7590
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top