Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!news.glorb.com!news.astraweb.com!border5.newsrouter.astraweb.com!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: those darn exceptions References: <96gb36Fc65U1@mid.individual.net> <96itucFadiU1@mid.individual.net> X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney Date: Sat, 25 Jun 2011 10:25:35 +1000 Message-ID: <87d3i2oiyo.fsf@benfinney.id.au> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:xFJwmv1NXOh2NmdQTgw5SavKYsE= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Lines: 33 Organization: Unlimited download news at news.astraweb.com NNTP-Posting-Host: f824e2ba.news.astraweb.com X-Trace: DXC=VH]>82Db@@9J0Z]=gbPP29L?0kYOcDh@:N7:H2`MmAU3F8TiH9LRjf1]G;2>V^?kW3bEW9A[5UK?5NZ[SL`C\Kg3kH[l9EU2439 Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8420 Chris Torek writes: > But again, this is why I would like to have the ability to use some > sort of automated tool, where one can point at any given line of > code and ask: "what exceptions do you, my faithful tool, believe > can be raised as a consequence of this line of code?" “Why, any exception at all”. > If you point it at the call to main(): > > if __name__ == '__main__': > main() > > then you are likely to get a useless answer ("why, any exception > at all"); but if you point it at a call to os.read(), then you get > one that is useful -- and tells you (or me) about the OverflowError. No. The answer is *still* “why, any exception at all”. The name ‘os.read’ could be re-bound at run-time to any object at all, so a code checker that you “point at any given line of code” can't know what the name will be bound to when that line gets executed. > If you point it at a call to len(x), then the tool tells you what > it knows about type(x) and x.__len__. Which information, before the code is executed, isn't determined. -- \ “The cost of education is trivial compared to the cost of | `\ ignorance.” —Thomas Jefferson | _o__) | Ben Finney