Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55111
| From | Dave Angel <davea@davea.name> |
|---|---|
| Subject | Re: Python Unit Tests |
| Date | 2013-09-30 20:20 +0000 |
| References | <bb6482de-ce4e-4dd2-845c-f71008123c03@googlegroups.com> <64c1fa97-ace1-4fee-83b0-cf5fd7230e82@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.504.1380572446.18130.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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