Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #16843

Re: Misleading error message of the day

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'value,': 0.04; 'raised': 0.07; 'correct.': 0.09; 'not?': 0.09; 'to:addr:comp.lang.python': 0.09; 'valueerror:': 0.09; 'subject:error': 0.09; 'exception': 0.12; 'def': 0.13; '"expected': 0.16; 'roy': 0.16; 'unpack': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; '(most': 0.21; 'header:In-Reply-To:1': 0.22; 'traceback': 0.24; 'saying': 0.26; 'fact': 0.27; 'temporary': 0.29; 'yield': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'values': 0.32; 'list': 0.32; 'received:209.85.161.46': 0.32; 'received :mail-fx0-f46.google.com': 0.32; 'message-id:@gmail.com': 0.33; 'header:User-Agent:1': 0.33; 'too': 0.34; 'last):': 0.34; 'file': 0.36; 'received:209.85.161': 0.36; 'cc:2**1': 0.36; 'gotten': 0.37; 'skip:" 10': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:10.0.0': 0.38; 'received:209.85': 0.38; 'returned': 0.39; 'should': 0.39; 'why': 0.39; "it's": 0.40; 'third': 0.40; 'received:209': 0.40; 'might': 0.40; 'more': 0.61; 'subject:day': 0.68; 'kept': 0.68; 'going,': 0.84; 'yielded': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=NNC13m4Nd89iFZ/ap0g7p++BesYV9W6l2Ah11m2URN4=; b=VYdSzrT48TitMbaGFnhXfpSMcn/4Nu8zpE2sTYiRsythokoLTRtXwIw3hFbRiVSnLu s4W0kDhCOQDqUENK5861KZIFPpVNIiqhizEB7g0J1FxsQIcfiGmL14alvN46V6jUkvfu 0/DIc9wVeIUEAxIpp49I+uT6ut7tNVBgoMZEY=
Date Thu, 08 Dec 2011 15:55:16 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111108 Thunderbird/8.0
MIME-Version 1.0
To comp.lang.python@googlegroups.com
Subject Re: Misleading error message of the day
References <roy-9DEDD9.09233308122011@news.panix.com> <jbqil6$esn$1@dough.gmane.org> <mailman.3417.1323357938.27778.python-list@python.org> <18647617.2258.1323358966076.JavaMail.geo-discussion-forums@yqf20>
In-Reply-To <18647617.2258.1323358966076.JavaMail.geo-discussion-forums@yqf20>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Cc python-list@python.org, Roy Smith <roy@panix.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3422.1323359720.27778.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1323359720 news.xs4all.nl 6852 [2001:888:2000:d::a6]:55887
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16843

Show key headers only | View raw


On 12/08/2011 03:42 PM, Roy Smith wrote:
>
> Why not?  Take this example:
>
> def i():
>      i = 0
>      while True:
>          print "returning:", i
>          yield i
>          i += 1
>
> a, b = i()
>
> ./iter.py
> returning: 0
> returning: 1
> returning: 2
> Traceback (most recent call last):
>    File "./iter.py", line 10, in<module>
>      a, b = i()
> ValueError: too many values to unpack
>
> The exception was raised when i() returned it's third value, so saying "expected 2, got 3" is exactly correct.  Yes, it is true that it might have gotten more if it kept going, but that's immaterial; the fact that it got to 3 is what caused the Holy Hand Grenade to be thrown.

Yes but how do you know how many values you generated when it quits?
I mean I don't know how it work internally, but it should keep a temporary
list of the yielded values to be able to find out how many values are 
there..

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 09:23 -0500
  Re: Misleading error message of the day Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-08 14:39 +0000
  Re: Misleading error message of the day Chris Angelico <rosuav@gmail.com> - 2011-12-09 01:40 +1100
  Re: Misleading error message of the day Robert Kern <robert.kern@gmail.com> - 2011-12-08 14:47 +0000
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:30 -0800
      Re: Misleading error message of the day Tim Chase <python.list@tim.thechases.com> - 2011-12-08 11:41 -0600
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:30 -0800
  Re: Misleading error message of the day Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-08 16:03 +0100
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:33 -0800
      Re: Misleading error message of the day Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-08 20:49 +0100
      Re: Misleading error message of the day Ethan Furman <ethan@stoneleaf.us> - 2011-12-08 12:13 -0800
      Re: Misleading error message of the day Lie Ryan <lie.1296@gmail.com> - 2011-12-09 12:46 +1100
        Re: Misleading error message of the day alex23 <wuwei23@gmail.com> - 2011-12-08 20:57 -0800
          Re: Misleading error message of the day Lie Ryan <lie.1296@gmail.com> - 2011-12-11 10:41 +1100
      Re: Misleading error message of the day Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-09 11:03 +0100
        Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-09 09:43 -0500
      Re: Misleading error message of the day Ethan Furman <ethan@stoneleaf.us> - 2011-12-09 09:39 -0800
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:33 -0800
      Re: Misleading error message of the day Grant Edwards <invalid@invalid.invalid> - 2011-12-08 18:10 +0000
        Re: Misleading error message of the day alister <alister.ware@ntlworld.com> - 2011-12-08 20:58 +0000
          Re: Misleading error message of the day Chris Angelico <rosuav@gmail.com> - 2011-12-09 08:17 +1100
        Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 20:19 -0500
        Re: Misleading error message of the day Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-09 02:07 +0000
          Re: Misleading error message of the day Chris Angelico <rosuav@gmail.com> - 2011-12-09 14:46 +1100
            Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 23:44 -0500
  Re: Misleading error message of the day Heiko Wundram <modelnine@modelnine.org> - 2011-12-08 16:16 +0100
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:42 -0800
      Re: Misleading error message of the day Heiko Wundram <modelnine@modelnine.org> - 2011-12-08 16:50 +0100
        Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 10:42 -0800
          Re: Misleading error message of the day Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-12-08 13:57 -0500
          Re: Misleading error message of the day Ethan Furman <ethan@stoneleaf.us> - 2011-12-08 11:09 -0800
          Re: Misleading error message of the day Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-12-08 14:38 -0500
          Re: Misleading error message of the day Ethan Furman <ethan@stoneleaf.us> - 2011-12-08 12:09 -0800
        Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 10:42 -0800
      Re: Misleading error message of the day Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-08 15:55 +0000
      Re: Misleading error message of the day Chris Angelico <rosuav@gmail.com> - 2011-12-09 03:21 +1100
      Re: Misleading error message of the day Robert Kern <robert.kern@gmail.com> - 2011-12-08 19:57 +0000
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:42 -0800

csiph-web