Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Importing the re module fails

Reply
Thread Tools

Importing the re module fails

 
 
Andreas Waldenburger
Guest
Posts: n/a
 
      12-07-2008
This is a little puzzling.


Using ipython:

[wildemar@localhost Logstuff]$ ipython
Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:3
Type "copyright", "credits" or "license" for more information.

[snip ipython help message]

In [1]: import re


This works fine. But with the regular python interpreter I get this:

[wildemar@localhost Logstuff]$ python
Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:3
[GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> import re

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/re.py", line 10, in <module>
# AB ((E-Mail Removed)).
AttributeError: 'module' object has no attribute 'compile'


What gives? Has Fedora-10 botched python or does anybody else have that
problem es well?

/W

--
My real email address is constructed by swapping the domain with the
recipient (local part).
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      12-07-2008
Andreas Waldenburger schrieb:
> This is a little puzzling.
>
>
> Using ipython:
>
> [wildemar@localhost Logstuff]$ ipython
> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:3
> Type "copyright", "credits" or "license" for more information.
>
> [snip ipython help message]
>
> In [1]: import re
>
>
> This works fine. But with the regular python interpreter I get this:
>
> [wildemar@localhost Logstuff]$ python
> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:3
> [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
> Type "help", "copyright", "credits" or "license" for more
> information.
> >>> import re

> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/python2.5/re.py", line 10, in <module>
> # AB ((E-Mail Removed)).
> AttributeError: 'module' object has no attribute 'compile'
>
>
> What gives? Has Fedora-10 botched python or does anybody else have that
> problem es well?


In my re.py module on line 10, there is no import - it has way to much
comments on the module beginning.

So - how does your /usr/lib/python2.5/re.py look like? And what about
some modules lying around (potentially *pycs) that mask system modules?

Diez
 
Reply With Quote
 
 
 
 
Andreas Waldenburger
Guest
Posts: n/a
 
      12-07-2008
On Sun, 07 Dec 2008 20:36:58 +0100 "Diez B. Roggisch"
<(E-Mail Removed)> wrote:

> Andreas Waldenburger schrieb:
> > This is a little puzzling.
> >
> >
> > Using ipython:
> >
> > [wildemar@localhost Logstuff]$ ipython
> > Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:3
> > Type "copyright", "credits" or "license" for more information.
> >
> > [snip ipython help message]
> >
> > In [1]: import re
> >
> >
> > This works fine. But with the regular python interpreter I get this:
> >
> > [wildemar@localhost Logstuff]$ python
> > Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:3
> > [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
> > Type "help", "copyright", "credits" or "license" for more
> > information.
> > >>> import re

> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > File "/usr/lib/python2.5/re.py", line 10, in <module>
> > # AB ((E-Mail Removed)).
> > AttributeError: 'module' object has no attribute 'compile'
> >
> >
> > What gives? Has Fedora-10 botched python or does anybody else have
> > that problem es well?

>
> In my re.py module on line 10, there is no import - it has way to
> much comments on the module beginning.
>
> So - how does your /usr/lib/python2.5/re.py look like?

Just like the error message says: " # AB ((E-Mail Removed))." on
line ten. That's what confused me so much (among being confused anyway).

> And what
> about some modules lying around (potentially *pycs) that mask system
> modules?
>

Bullseye. I had a re.pyc in the current directory, because I stupidly
created a testbed called re.py. Realizing my folly I renamed it to
something else, while forgetting to delete the already created re.pyc.

Thanks, and sorry for the noise. (I do wonder why ipython didn't
complain, though.)


/W
--
My real email address is constructed by swapping the domain with the
recipient (local part).
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
importing site fails - why? Helmut Jarausch Python 3 11-12-2010 07:35 PM
Importing Module To Use Variables In A Second Module rshepard@nospam.appl-ecosys.com Python 4 09-28-2007 01:17 PM
doubt with importing module, given module name Pradnyesh Sawant Python 0 04-09-2007 05:22 PM
How to keep a module with the same name as a module it is importing from importing itself? plb Python 2 02-08-2005 03:14 PM
Importing WMI module into Python CGI script fails MK Python 4 07-20-2003 08:24 PM



Advertisments