Try: rather than if :
Vincent Davis
vincent at vincentdavis.net
Mon Dec 14 17:38:05 EST 2015
In the code below try is used to check if handle has the attribute name. It
seems an if statement could be used. Is there reason one way would be
better than another?
def write_header(self):
handle = self.handle
try:
handle.write("# Report_file: %s\n" % handle.name)
except AttributeError:
pass
handle.write("########################################\n")
The specific use case I noticed this was
https://github.com/biopython/biopython/blob/master/Bio/AlignIO/EmbossIO.py#L38
Vincent Davis
More information about the Python-list
mailing list