My python interpreter became mad !

B

Benjamin Watine

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.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. The code showed, is
a previous test code, that seems to be buffered and that make an error.
Each call to re module generate that error.

How can I workaround ? Is there is a way to flush or restart python
interpreter. Is it a bug in python ??

Thanks !

Ben
 
A

alex23

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 :

The following line in the traceback shows you're not using the default
python module:
File "/etc/postfix/re.py", line 19, in ?

Were you using the interpreter in the /etc/postfix directory? The re
module there seems to be shadowing the site package.

Hope this helps.

- alex23
 
J

John Machin

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.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.
 
B

Benjamin Watine

John Machin a écrit :
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
 
J

John Machin

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:
""""""

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]

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.
 
J

John Machin

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?
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:
""""""

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.
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.
 
G

Gabriel Genellina

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.

Perhaps *you* would do that, but that is far beyond a newbie would do.
Most newbies are lost enough to not even be able to ask the question in
the first place. If the book doesn't tell anything about the directory,
why should the starting directory be relevant? Why should I care not to
use a reserved name to save my script? Where is that list of reserved
names?
 
C

castironpi

Furkan Kuru incorrigibly top-posted:



I don't understand that sentence.


Why would/should we assume that?

Process of enumeration.
and achieve the same result: importing the bogus re. What's your point?

I'm not so sure that dispute burdens of proof are resolved all that
virtuously (life isn't fair; fair is good). What are newsgroups like
in the monarchies? Ever feel you're typing on auto-pilot? It's not
like you vote on me staying. However, the things I've said about
myself aren't written intepretation-strict, thence there must be some
distinction between interpretations, or between resident attitudes for
me?

Perhaps my fault for overinvesting hope in the newsgroups. You're not
a best friend to me! <awkward>. If you look like your pets, do we
look like computers? Restrictions are different for justice: my only
analytically (or never) outweighs my threshold.

By the process of cognition, we ascribe malice (how probabilistically-
malicious is it) to people (as danger to objects?), but the ideal
realm (kingdom Logos), but revising estimates is expensive.

Do visual mirrors make a round-trip error?

Is there emotionally such thing as a computer? They are certainly
deep, but perhaps only axiomatically; people aren't made of binary.
How far to the nearest indefinite precision computer? Any pull around
here? Someone have a thesis on wake-detection in a parallel system?
Can we 'black-box' people? ("Are you a black box?") What kind of
accuracy is there in uniform media? Can we 'black-box' groups?

Wakes and patterned perturbations can be modeled in feature-sets,
abitrary feature collisions not fully particle. I'd be more
interested in a feature specialty that facilitates to transmit waves,
and a sum-of-waveform native. Is there a recursive expression of the
taylor expansion of e^x, by the way?

Interface and deface. Honest and true? Can you just buffer?

Beliefs might settle wrong, and it's hard to change them: huge
machine, right nail. Can a spider swarm simulate a macro operation
(building a building), either given a power source or carrying
"lifeform batteries"? Operator would need interface: thought to
operation: fast enough - idle loop cost: can't be governing every
small bug (once again, features over particles), the machines would
need overall/level/summary operations, read memories. But you can get
a couple microvolts and a memory cell on a 2-micron spider, and a
radio-static but sees a medium, speed-of-propogation, limitation.
Just think outside the case.

How organized is the newsgroup? Can I buy a long non-commutative
associative (time order (resort)) record? It's not. (That's a tongue
thing, right?) A place to come to: a place to sit at energy level.
(New you vs. same me here too.) 2-D primitives suck on serial input.
I'd almost rather decode a video of hands. Would a computer mind
learning?

You could by a perceptive-order code. What the world needs is a few
good spacers. I have to think; leave silent, and return broadcasting.

How's yours suck + what's the monkey on your back? Multi-type time
people for sale, American dollar. Anyone up for a little register-
base broadcasting? It's a broad.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top