<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2657.73">
<TITLE>RE: [Pyrex] Total newbie needs code review</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Chris,</FONT>
</P>
<P><FONT SIZE=2>Overall your code looks fine. A few things to consider though:</FONT>
</P>
<P><FONT SIZE=2>> class Analyzer:</FONT>
<BR><FONT SIZE=2>> def __init__(self, fname):</FONT>
<BR><FONT SIZE=2>> ret = init(fname)</FONT>
<BR><FONT SIZE=2>> if ret != 0:</FONT>
<BR><FONT SIZE=2>> raise "init failed, returned %d" % ret</FONT>
</P>
<P><FONT SIZE=2>raising string exceptions is deprecated and will be removed in python 3. The preferred method of raising exceptions is:</FONT>
</P>
<P> <FONT SIZE=2>raise ExceptionClass(*args **kwargs)</FONT>
</P>
<P><FONT SIZE=2>so your call should be:</FONT>
</P>
<P> <FONT SIZE=2>raise Exception("init failed, returned %d" % ret)</FONT>
</P>
<P><FONT SIZE=2>or preferably define your own exception as a trivial subclass of Exception giving it a more meaningful name.</FONT>
</P>
<P><FONT SIZE=2>Second, be aware that when assigning python strings to char pointers in Pyrex the reference returned points to the memory where the python string is stored. This memory should not be modified external to calls using the python/c api so any functions that modify it must malloc the string pointer and copy the python string into it instead.</FONT></P>
<P><FONT SIZE=2>Regards,</FONT>
</P>
<P><FONT SIZE=2>Grant M.</FONT>
</P>
</BODY>
<!--[object_id=#infocomp.com#]--><P><FONT face=Arial color=#808080 size=1>Important notice: This message is intended for the individual(s) and entity(s) addressed. The information contained in this transmission and any attached, may be confidential and may also be the subject of legal privilege, public interest immunity or legal professional privilege. Any review, retransmission, dissemination or other use of, taking of any action in reliance upon this information by person or entities other than the recipient is prohibited and requires authorization from the sender. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person) you may not copy or deliver this message to anyone. In such cases you should destroy this message and kindly notify the sender by reply email. </FONT></P>
<P><FONT face=Arial color=#808080 size=1>WARNING: Although Infocomp has taken reasonable precautions so that no viruses are present in this e-mail, the company cannot accept responsibility for any loss or damage arising from the use of e-mail attachments.</FONT></P></HTML>