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


Groups > comp.lang.python > #55111

Re: Python Unit Tests

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'value,': 0.04; 'subject:Python': 0.06; '(all': 0.07; 'error:': 0.07; 'tries': 0.07; '34,': 0.09; 'falls': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'used)': 0.09; 'def': 0.12; 'b):': 0.16; 'buggy': 0.16; 'clause,': 0.16; 'expression.': 0.16; 'iterable': 0.16; 'none.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'specific,': 0.16; 'splitting': 0.16; 'temp': 0.16; 'tuple': 0.16; 'tuple,': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'app': 0.19; 'code,': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'body,': 0.24; 'interpret': 0.24; 'source': 0.25; 'second': 0.26; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'is?': 0.30; "i'm": 0.30; 'code': 0.31; 'end,': 0.31; 'equivalent.': 0.31; 'file': 0.32; 'says': 0.33; '(most': 0.33; 'guess': 0.33; "i'd": 0.34; 'but': 0.35; 'add': 0.35; 'returning': 0.36; 'doing': 0.36; 'next': 0.36; 'charset:us-ascii': 0.36; 'example,': 0.37; 'two': 0.37; 'starting': 0.37; 'to:addr:python- list': 0.38; 'list,': 0.38; 'recent': 0.39; 'realize': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'remove': 0.60; 'tell': 0.60; 'simply': 0.61; "you're": 0.61; 'email addr:gmail.com': 0.63; 'provide': 0.64; 'side': 0.67; 'hang': 0.67; 'line,': 0.68; 'further,': 0.74; 'lol,': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re: Python Unit Tests
Date Mon, 30 Sep 2013 20:20:24 +0000 (UTC)
References <bb6482de-ce4e-4dd2-845c-f71008123c03@googlegroups.com> <64c1fa97-ace1-4fee-83b0-cf5fd7230e82@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 174.32.174.35
User-Agent XPN/1.2.6 (Street Spirit ; Linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.504.1380572446.18130.python-list@python.org> (permalink)
Lines 57
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1380572446 news.xs4all.nl 15983 [2001:888:2000:d::a6]:33553
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:55111

Show key headers only | View raw


On 30/9/2013 15:54, melwin9@gmail.com wrote:

> Lol, im starting to get the hang out of, onto the next hurdle, i looked up the error and it says the data is none?
>
> Traceback (most recent call last):
>   File "guess.py", line 34, in <module>
>     main(random.randint(1, 10)) 
>   File "guess.py", line 27, in main
>     guess, tries = getguess(target, allowed)
> TypeError: 'NoneType' object is not iterable
>
>

Please don't top-post.  Further, if you insist on using a buggy app like
googlegroups, at least remove all the stupid double-spacing.

Do you know how to interpret this error message?  The line that fails is
    guess, tries = getguess(target, allowed)


So can you tell what the None data is?  You're doing a tuple-unpack on
the left side of the equals, so the right side needs to be a tuple,
list, or equivalent.  In specific, an iterable.

Now you reread the error, and realize that the getguess() function is
returning None.

If I were a novice, I'd start by splitting up the line with the error:

   temp =  getguess(target, allowed)
   guess, tries = temp

Then when the error complains about the second line, I'd add a print
statement:

   temp =  getguess(target, allowed)
   print(repr(temp))
   guess, tries = temp

Lacking the source code, I'm going to guess that some path through your
code is missing a return expression.

For example, you might have

def  getguess(a, b):
     if a < b:
        return a, a*b

So it'll return a tuple of two items in the if body, but without an else
clause, it simply falls off the end, and returns None.  (All functions
return something, so if you don't provide a value, None is used)


-- 
DaveA

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


Thread

Python Unit Tests melwin9@gmail.com - 2013-09-27 21:52 -0700
  Re: Python Unit Tests Dave Angel <davea@davea.name> - 2013-09-28 06:11 +0000
  Re: Python Unit Tests Terry Reedy <tjreedy@udel.edu> - 2013-09-28 14:47 -0400
    Re: Python Unit Tests melwin9@gmail.com - 2013-09-29 18:46 -0700
      Re: Python Unit Tests Steven D'Aprano <steve@pearwood.info> - 2013-09-30 02:55 +0000
        Re: Python Unit Tests melwin9@gmail.com - 2013-09-29 21:19 -0700
          Re: Python Unit Tests Terry Reedy <tjreedy@udel.edu> - 2013-09-30 02:08 -0400
  Re: Python Unit Tests melwin9@gmail.com - 2013-09-30 12:54 -0700
    Re: Python Unit Tests MRAB <python@mrabarnett.plus.com> - 2013-09-30 21:08 +0100
    Re: Python Unit Tests Dave Angel <davea@davea.name> - 2013-09-30 20:20 +0000
    Re: Python Unit Tests Terry Reedy <tjreedy@udel.edu> - 2013-09-30 20:06 -0400

csiph-web