My python interpreter became mad !
Benjamin Watine
watine at cines.fr
Tue Mar 25 09:50:51 EDT 2008
John Machin a écrit :
> On Mar 25, 10:05 pm, Benjamin Watine <wat... at cines.fr> wrote:
>> Yes, my python interpreter seems to became mad ; or may be it's me ! :)
>>
>> I'm trying to use re module to match text with regular expression. In a
>> first time, all works right. But since yesterday, I have a very strange
>> behaviour :
>>
>> $ python2.4
>> Python 2.4.4 (#2, Apr 5 2007, 20:11:18)
>> [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import re
>> X-Spam-Flag: YES
>> X-Spam-Checker-Version: SpamAssassin 3.1.7-deb (2006-10-05) on w3hosting.org
>> X-Spam-Level: **********************
>> X-Spam-Status: Yes, score=22.2 required=5.0 tests=MISSING_HB_SEP,
>> MISSING_HEADERS,MISSING_SUBJECT,RAZOR2_CF_RANGE_51_100,
>>
>> RAZOR2_CF_RANGE_E8_51_100,RAZOR2_CHECK,TO_CC_NONE,UNPARSEABLE_RELAY,
>>
>> URIBL_AB_SURBL,URIBL_JP_SURBL,URIBL_OB_SURBL,URIBL_SBL,URIBL_SC_SURBL,
>> URIBL_WS_SURBL autolearn=failed version=3.1.7-deb
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>> File "/etc/postfix/re.py", line 19, in ?
>> m = re.match('(Spam)', mail)
>> AttributeError: 'module' object has no attribute 'match'
>> >>>
>>
>> What's the hell ?? I'm just importing the re module.
>
> No you're not importing *the* re module. You're importing *an* re
> module, the first one that is found. In this case: your own re.py.
> Rename it.
>
Oh... yes, that's it ; I have a file named re.py !
Ouch, sorry for this stupid question, and thank you for this evident
answer. I didn't knew that it was possible to import a module this way...
Thank you for the fast answer !
Ben
More information about the Python-list
mailing list