<div> </div>
<div><br><br> </div>
<div><span class="gmail_quote">On 3/26/08, <b class="gmail_sendername">John Machin</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sjmachin@lexicon.net" target="_blank">sjmachin@lexicon.net</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>> but I did not give it a chance "not trying python interpreter in another<br>> directory"<br>
<br>I don't understand that sentence.</blockquote>
<div> </div>
<div>ok let me explain:</div>
<div>I did not think he/she/anyone would ask the question in the main thread without trying the interpreter a few times starting it from different directories. </div>
<div> </div>
<div> </div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">> so if we assume the problem exists in every directory, it has something<br>> to do with pythonpath.<br>
<br>Why would/should we assume that?</blockquote>
<div> </div>
<div> </div>
<div>Because I, as an individual, would not ask this question without running interpreter from different directories.</div>
<div>and I would look whether I created a py file with the exact same name of a core module. </div>
<div> </div>
<div>And this "simple" mistake had been pointed out by other guys. </div>
<div>The only other reason that came to my mind was this pythonpath. </div>
<div>( and I was dealing with it recently: you may have take a look at the thread titled 'embedded pyton pythonpath' any answer is appreciated :p )<br> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">> you can try setting pythonpath to some directory and put a re.py there<br>> and try from any directory starting your interpreter and importing re.<br>
<br>and achieve the same result: importing the bogus re. What's your point?</blockquote>
<div> </div>
<div> </div>
<div>yeah same result: bogus re. but from a different way: not user's re but created by someone else in another directory. </div>
<div> </div>
<div> </div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">><br>><br>><br>> On 3/25/08, *John Machin* <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sjmachin@lexicon.net" target="_blank">sjmachin@lexicon.net</a><br>
> <mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sjmachin@lexicon.net" target="_blank">sjmachin@lexicon.net</a>>> wrote:<br>><br>> Furkan Kuru top-posted:<br>> > Most probably X-Spam added itself to your path.<br>
><br>> What is "X-Spam"? Added itself to Benjamin's path [not mine] in such a<br>> fashion that it is invoked when one does "import re"?<br>><br>> > you should look at your PATH and PYTHONPATH environment variables.<br>
><br>> Most *IM*probably. Read the traceback:<br>> """<br>> > > File "/etc/postfix/re.py", line 19, in ?<br>> > > m = re.match('(Spam)', mail)<br>
> > > AttributeError: 'module' object has no attribute 'match'<br>> """<br>><br>> This is a classic case of a script (which does not guard against side<br>
> effects (like spewing out gibberish) when imported instead of being<br>> executed) being given the same name as a Python-included module and<br>> being executed in the current directory and hence ends up importing<br>
> itself.<br>><br>> ><br>> > On Tue, Mar 25, 2008 at 1:40 PM, John Machin<br>> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sjmachin@lexicon.net" target="_blank">sjmachin@lexicon.net</a> <mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sjmachin@lexicon.net" target="_blank">sjmachin@lexicon.net</a>><br>
> > <mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sjmachin@lexicon.net" target="_blank">sjmachin@lexicon.net</a> <mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sjmachin@lexicon.net" target="_blank">sjmachin@lexicon.net</a>>>> wrote:<br>
> ><br>> > On Mar 25, 10:05 pm, Benjamin Watine <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:wat...@cines.fr" target="_blank">wat...@cines.fr</a><br>> <mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:wat...@cines.fr" target="_blank">wat...@cines.fr</a>><br>
> > <mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:wat...@cines.fr" target="_blank">wat...@cines.fr</a> <mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:wat...@cines.fr" target="_blank">wat...@cines.fr</a>>>> wrote:<br>
> > > Yes, my python interpreter seems to became mad ; or may be<br>> it's<br>> > me ! :)<br>> > ><br>> > > I'm trying to use re module to match text with regular<br>
> > expression. In a<br>> > > first time, all works right. But since yesterday, I have a<br>> very<br>> > strange<br>> > > behaviour :<br>> > ><br>
> > > $ python2.4<br>> > > Python 2.4.4 (#2, Apr 5 2007, 20:11:18)<br>> > > [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2<br>> > > Type "help", "copyright", "credits" or "license" for more<br>
> > information.<br>> > > >>> import re<br>> > > X-Spam-Flag: YES<br>><br>> [snip]<br>><br>> > > Traceback (most recent call last):<br>
> > > File "<stdin>", line 1, in ?<br>> > > File "/etc/postfix/re.py", line 19, in ?<br>> > > m = re.match('(Spam)', mail)<br>
> > > AttributeError: 'module' object has no attribute 'match'<br>> > > >>><br>> > ><br>> > > What's the hell ?? I'm just importing the re module.<br>
> ><br>> > No you're not importing *the* re module. You're importing *an* re<br>> > module, the first one that is found. In this case: your own<br>> re.py.<br>> > Rename it.<br>
> ><br>><br>><br>><br>><br>> --<br>> Furkan Kuru<br><br></blockquote></div><br><br clear="all"><br>-- <br>Furkan Kuru