[Tutor] about a function
alan.gauld@bt.com
alan.gauld@bt.com
Tue Mar 25 09:25:01 2003
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C2F2DA.25C11B80
Content-Type: text/plain;
charset="iso-8859-1"
> it stops giving me a an error like as follows:
File "Ass-002.py", line 30, in EQNfunc
reslt = temp.group()
AttributeError: 'NoneType' object has no attribute 'group'
Have you checked what kind of object temp is?
If your search fails it returns None. none does not have a group()
attribute,
hence the error.
You need to either handle the exception (the Pythonic solution) or test to
see if its not None:
if temp != None:
res = temp.group()
Thats my guess! :-)
Alan G.
------_=_NextPart_001_01C2F2DA.25C11B80
Content-Type: text/html;
charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4923.2500" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=214142114-25032003><FONT face=Arial color=#0000ff
size=2> > </FONT></SPAN>it stops giving me a an error like as
follows:</DIV>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid">
<P> File "Ass-002.py", line 30, in EQNfunc<BR> reslt =
temp.group()<BR>AttributeError: 'NoneType' object has no attribute
'group'</P></BLOCKQUOTE>
<P><SPAN class=214142114-25032003><FONT face=Arial color=#0000ff size=2>Have you
checked what kind of object temp is?</FONT></SPAN></P>
<P><SPAN class=214142114-25032003><FONT face=Arial color=#0000ff size=2>If your
search fails it returns None. none does not have a group() attribute,
<BR></FONT></SPAN><SPAN class=214142114-25032003><FONT face=Arial color=#0000ff
size=2>hence the error.</FONT></SPAN></P>
<P><SPAN class=214142114-25032003><FONT face=Arial color=#0000ff size=2>You need
to either handle the exception (the Pythonic solution) or test to <BR>see if its
not None:</FONT></SPAN></P>
<P><SPAN class=214142114-25032003><FONT face=Arial color=#0000ff size=2>if temp
!= None: <BR> </FONT></SPAN><SPAN
class=214142114-25032003><FONT face=Arial color=#0000ff size=2>res =
temp.group()</FONT></SPAN></P>
<P><SPAN class=214142114-25032003><FONT face=Arial color=#0000ff size=2>Thats my
guess! :-)</FONT></SPAN></P>
<P><SPAN class=214142114-25032003><FONT face=Arial color=#0000ff size=2>Alan
G.</FONT></SPAN></P></BODY></HTML>
------_=_NextPart_001_01C2F2DA.25C11B80--