My python interpreter became mad !
Furkan Kuru
furkankuru at gmail.com
Tue Mar 25 21:14:39 EDT 2008
On 3/26/08, John Machin <sjmachin at lexicon.net> wrote:
>
>
> > but I did not give it a chance "not trying python interpreter in another
> > directory"
>
> I don't understand that sentence.
ok let me explain:
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.
> so if we assume the problem exists in every directory, it has something
> > to do with pythonpath.
>
> Why would/should we assume that?
Because I, as an individual, would not ask this question without running
interpreter from different directories.
and I would look whether I created a py file with the exact same name of a
core module.
And this "simple" mistake had been pointed out by other guys.
The only other reason that came to my mind was this pythonpath.
( 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 )
> > 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?
yeah same result: bogus re. but from a different way: not user's re but
created by someone else in another directory.
>
> >
> >
> > On 3/25/08, *John Machin* <sjmachin at lexicon.net
> > <mailto:sjmachin at lexicon.net>> 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
> > <sjmachin at lexicon.net <mailto:sjmachin at lexicon.net>
> > > <mailto:sjmachin at lexicon.net <mailto:sjmachin at lexicon.net>>>
> wrote:
> > >
> > > On Mar 25, 10:05 pm, Benjamin Watine <wat... at cines.fr
> > <mailto:wat... at cines.fr>
> > > <mailto:wat... at cines.fr <mailto: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
> >
> > [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
>
>
--
Furkan Kuru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080326/5434b604/attachment.html>
More information about the Python-list
mailing list