Furkan Kuru incorrigibly top-posted: > Ok, you're right. > > but I did not give it a chance "not trying python interpreter in another > directory"
I don't understand that sentence. > so if we assume the problem exists in every directory, it has something > to do with pythonpath. Why would/should we assume that? > you can try setting pythonpath to some directory and put a re.py there > and try from any directory starting your interpreter and importing re. and achieve the same result: importing the bogus re. What's your point? > > > > On 3/25/08, *John Machin* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Furkan Kuru top-posted: > > Most probably X-Spam added itself to your path. > > What is "X-Spam"? Added itself to Benjamin's path [not mine] in such a > fashion that it is invoked when one does "import re"? > > > you should look at your PATH and PYTHONPATH environment variables. > > Most *IM*probably. Read the traceback: > """ > > > File "/etc/postfix/re.py", line 19, in ? > > > m = re.match('(Spam)', mail) > > > AttributeError: 'module' object has no attribute 'match' > """ > > This is a classic case of a script (which does not guard against side > effects (like spewing out gibberish) when imported instead of being > executed) being given the same name as a Python-included module and > being executed in the current directory and hence ends up importing > itself. > > > > > On Tue, Mar 25, 2008 at 1:40 PM, John Machin > <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote: > > > > On Mar 25, 10:05 pm, Benjamin Watine <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> 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 > > [snip] > > > > 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. > > > > > > > -- > Furkan Kuru -- http://mail.python.org/mailman/listinfo/python-list