<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 05/26/2010 10:48 AM, William Miner wrote:
<blockquote cite="mid:C822D73A.52F0%25william.miner@enig.com"
type="cite">
<title>Error</title>
<font face="Calibri, Verdana, Helvetica, Arial"><span
style="font-size: 11pt;">I’m relative new to python and I puzzled by
the following strange (to me) behavior. I was taking pieces from two
old scripts to build a new one. When I began to debug it I got the
following error message:<br>
<br>
Traceback (most recent call last):<br>
File
"/Users/williamminer/ex2gen/ex2gen-3.0.5/src/ScriptDev/run_ex2gen_scan.py",
line 38, in <module><br>
if re.search('varm',line):<br>
AttributeError: 'function' object has no attribute 'search'<br>
<br>
This had worked in the previous script but not the new one. I noticed
that the new script had an additional line at the beginning (line 3)<br>
<br>
#!/usr/bin/env python<br>
import sys, math, os, shutil, commands, re, mpmath<br>
from mpmath import *<br>
<br>
When I deleted this line, the script ran. Why did the line<br>
<br>
from mpmath import *<br>
</span></font></blockquote>
<br>
Just a guess, (since I don;t have <font
face="Calibri, Verdana, Helvetica, Arial"><span
style="font-size: 11pt;">mpmath on hand), but if mpmath has a
definition for something named re, it would overwrite any previous
definition of re.</span></font><br>
<br>
So general advice says don't use the "from xxx import *" unless you
really *know* what is in the module, and need *all* of it imported. <br>
<br>
Either:<br>
from mpmath import x,y,z,whatever<br>
<br>
or<br>
import re<br>
import mpmath<br>
... re.search ...<br>
... mpmath.whatever ...<br>
<br>
<br>
<br>
Gary Herron<br>
<br>
<br>
<br>
<br>
<blockquote cite="mid:C822D73A.52F0%25william.miner@enig.com"
type="cite"><font face="Calibri, Verdana, Helvetica, Arial"><span
style="font-size: 11pt;"><br>
Trash the search function fro the regular expression module?<br>
<br>
I’m running Python 2.6.2 on Mac running OS 10.6.3.<br>
<br>
Thanks!<br>
<br>
Buff Miner<br>
</span></font><span style="font-size: 11pt;"><font
face="Lucida Calligraphy">-- <br>
</font></span><font face="Lucida Calligraphy"><font size="1"><span
style="font-size: 9pt;">Enig Associates, Inc.<br>
Suite 500, Bethesda Crescent Bldg.<br>
4600 East West Hwy<br>
Bethesda, Maryland 20814<br>
Tel:(301)680-8600<br>
Fax:(301)680-8100<br>
<br>
This message is intended only for the use of the intended recipient(s),
and<br>
it may be privileged and confidential. If you are not the intended<br>
recipient, you are hereby notified that any review, retransmission,<br>
conversion to hard copy, copying, circulation or other use of this
message<br>
is strictly prohibited and may be illegal. If you are not the intended<br>
recipient, please notify the sender immediately by return e-mail, and
delete<br>
this message from your system. Thank you.<br>
</span></font></font><font face="Calibri, Verdana, Helvetica, Arial"><span
style="font-size: 11pt;"><br>
</span></font>
</blockquote>
<br>
</body>
</html>