Re: Newbie naive question ... int() throws ValueError

2012-05-12 Thread Chris Angelico
On Sun, May 13, 2012 at 4:25 AM, Devin Jeanpierre wrote: > What having to try-it-and-see does is give me extra steps to know what > it does. Instead of only reading the documentation, now I have to both > read the documentation *and* try it out in the interactive interpreter > to see its behaviour

Re: Newbie naive question ... int() throws ValueError

2012-05-12 Thread Devin Jeanpierre
On Sat, May 12, 2012 at 8:27 AM, Karl Knechtel wrote: > I really wish gmail picked up the mailing list as a default reply-to > address... There is some labs thing that makes "reply to all" the default if you click the button on the top-right. Unfortunately, that applies for non-mailing-lists too

Re: Newbie naive question ... int() throws ValueError

2012-05-12 Thread Ethan Furman
Devin Jeanpierre wrote: On Fri, May 11, 2012 at 11:21 PM, Chris Angelico wrote: There are times when you want to catch all exceptions, though. Top-level code will often want to replace exception tracebacks with error messages appropriate to some external caller, or possibly log the exception an

Fwd: Newbie naive question ... int() throws ValueError

2012-05-12 Thread Karl Knechtel
I really wish gmail picked up the mailing list as a default reply-to address... -- Forwarded message -- From: Karl Knechtel Date: Sat, May 12, 2012 at 8:25 AM Subject: Re: Newbie naive question ... int() throws ValueError To: Devin Jeanpierre On Sat, May 12, 2012 at 12:11 AM

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread Chris Angelico
On Sat, May 12, 2012 at 2:11 PM, Devin Jeanpierre wrote: > I'm not talking about unexpected exceptions. I'm saying, if I expect > invalid input for int, where should I go to find out how to deal with > said invalid input properly? How do I know that int raises ValueError > on failure, and not, for

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread Devin Jeanpierre
On Fri, May 11, 2012 at 11:21 PM, Chris Angelico wrote: > There are times when you want to catch all exceptions, though. > Top-level code will often want to replace exception tracebacks with > error messages appropriate to some external caller, or possibly log > the exception and return to some pr

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread Chris Angelico
On Sat, May 12, 2012 at 5:34 AM, Devin Jeanpierre wrote: > On Fri, May 11, 2012 at 2:10 AM, Chris Angelico wrote: >> Unlike in Java, a function's list of things it can throw isn't part of >> its signature. Instead of trying to catch every possible exception, >> it's generally best to simply let e

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread Devin Jeanpierre
On Fri, May 11, 2012 at 2:10 AM, Chris Angelico wrote: > Unlike in Java, a function's list of things it can throw isn't part of > its signature. Instead of trying to catch every possible exception, > it's generally best to simply let exceptions propagate unless you KNOW > you're expecting them. H

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread John Terrak
Thank you all for your help. Greatly appreciated. John -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread Chris Angelico
On Sat, May 12, 2012 at 3:12 AM, Ian Kelly wrote: > I believe that a MemoryError instance is pre-allocated for just this > scenario. Ah, wise move. It's one of those largely-imponderables, like figuring out how to alert the sysadmin to a router failure. ChrisA -- http://mail.python.org/mailman/

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread Ian Kelly
On Fri, May 11, 2012 at 10:23 AM, Chris Angelico wrote: > Hmm. What happens if the interpreter can't construct a MemoryError exception? I believe that a MemoryError instance is pre-allocated for just this scenario. You can see it in the result of gc.get_objects(). >>> [x for x in gc.get_objects

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread Chris Angelico
On Sat, May 12, 2012 at 2:15 AM, Christian Heimes wrote: > Am 11.05.2012 17:51, schrieb Terry Reedy: >> If the domain of a function is truly all Python objects, it cannot raise >> an error. I believe id(x) is such an example. > > Even id() can raise an exception, for example MemoryError when you a

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread Christian Heimes
Am 11.05.2012 17:51, schrieb Terry Reedy: > If the domain of a function is truly all Python objects, it cannot raise > an error. I believe id(x) is such an example. Even id() can raise an exception, for example MemoryError when you are running out of memory. Christian -- http://mail.python.org/

Re: Newbie naive question ... int() throws ValueError

2012-05-11 Thread Terry Reedy
On 5/11/2012 1:55 AM, John Terrak wrote: I couldnt find anywhere in the documentation that int() can throw a ValueError. I checked the "The Python Language Reference", and the "The Python Standard Library " to no avail. Did I missed something? To add to Chris' answer: If the domain of a funct

Re: Newbie naive question ... int() throws ValueError

2012-05-10 Thread Chris Angelico
On Fri, May 11, 2012 at 3:55 PM, John Terrak wrote: > I couldnt find anywhere in the documentation that int() can throw a > ValueError. > I checked the "The Python Language Reference", and the "The Python > Standard Library " to no avail. > Did I missed something? Unlike in Java, a function's li

Newbie naive question ... int() throws ValueError

2012-05-10 Thread John Terrak
Hi Sorry for such a naive question. I couldnt find anywhere in the documentation that int() can throw a ValueError. I checked the "The Python Language Reference", and the "The Python Standard Library " to no avail. Did I missed something? So here is the question - if it is not in the documentati