Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100433 > unrolled thread
| Started by | Vincent Davis <vincent@vincentdavis.net> |
|---|---|
| First post | 2015-12-14 15:38 -0700 |
| Last post | 2015-12-14 15:38 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Try: rather than if : Vincent Davis <vincent@vincentdavis.net> - 2015-12-14 15:38 -0700
| From | Vincent Davis <vincent@vincentdavis.net> |
|---|---|
| Date | 2015-12-14 15:38 -0700 |
| Subject | Try: rather than if : |
| Message-ID | <mailman.17.1450133168.14916.python-list@python.org> |
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
Back to top | Article view | comp.lang.python
csiph-web