<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 25, 2016 at 6:58 AM, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> >>> tuple(foo)<br>
><br>
> TypeError: 'int' object is not iterable<br>
><br>
> No raiser, no value given. It's hard to find out what's the problem is. The<br>
> biggest issue here is that if you have a long line with tuple() in the<br>
> middle, yuou need to know the problem comes from tuple.<br>
><br>
> Another problem is that many people don't know what iterable means.<br>
><br>
> A better error message would be:<br>
><br>
> TypeError: tuple() only accept iterables (any object you can use a for loop<br>
> on). But it received '1', which is of type <int>.<br>
<br>
</span>-1 on this one. It doesn't really add very much - "iterable" is a good<br>
keyword that anyone can put into a search engine. </blockquote><div><br></div><div>yes, that's OK -- and that is the spec of the tuple constructor, yes?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Adding the repr of<br>
the object that was passed is nice if it's an integer, but less so if<br>
you passed in some huge object.<br></blockquote><div><br></div><div>I'm not sure you need the repr of the object passed in -- the type is usually sufficient. (for a TypeError -- for a ValueError, then the value IS important, and a repr is nice.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If your lines of code are so complicated that you can't pinpoint the<br>
cause of the TypeError, the solution is probably to break the line.</blockquote><div><br></div><div>yes, but it would be nice not to have to -- maybe I'm just overdoing the one-liners, but I VERY often have errors liek this on a line, and have to go in and break the line by hand to find out where the error is actually coming from.</div><div><br></div><div>SyntaxErrors make some effort to indicate WHERE in the line the Error is - it would be great to get some help like that in these cases. Not sure how possible it is though.</div><div><br></div><div>As I think about it, I tend to get this with indexing error, where a have a fairly complex expression with multiple objects being indexed, and then a get an IndexError and have no idea where the problem is.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> SyntaxError: bytes can only contain ASCII literal characters.<br>
><br>
> This is not helpful to somebody unaware of the difference between text and<br>
> bytes.<br>
<br>
</span>Someone unaware of the difference between text and bytes probably<br>
isn't messing with code that has b"..." strings in it.</blockquote><div><br></div><div>or shouldn't be :-)</div><div> </div><div><br></div></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>