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


Groups > comp.lang.python > #97830

Re: unsupported operand type(s) python v2.7

Path csiph.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!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.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'operand': 0.07; 'none.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'typeerror:': 0.09; 'exception': 0.13; 'def': 0.13; 'subject:python': 0.14; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'seeing.': 0.16; 'subject:type': 0.16; 'unsupported': 0.16; 'wrote:': 0.16; '"",': 0.22; 'explicit': 0.22; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'received:132': 0.29; 'subject:) ': 0.32; 'traceback': 0.33; 'file': 0.34; 'add': 0.34; 'so,': 0.35; 'attempt': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'doing': 0.38; 'to:addr:python.org': 0.40; 'your': 0.60; 'away,': 0.84; 'calculations': 0.84; 'type(s)': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de>
Subject Re: unsupported operand type(s) python v2.7
Date Tue, 20 Oct 2015 11:00:08 +0200
References <695863e0-7c7b-4739-bbc7-6719e40133fb@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 132.230.194.87
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
In-Reply-To <695863e0-7c7b-4739-bbc7-6719e40133fb@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.49.1445331653.878.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1445331653 news.xs4all.nl 23750 [2001:888:2000:d::a6]:57348
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:97830

Show key headers only | View raw


On 20.10.2015 10:44, ngangsia akumbo wrote:
>>>> def n():
> 	34 * 2
>
> 	
>>>> def g():
> 	4 + 2
>

Your n and g functions do not have an explicit return so, after doing 
their calculations and throwing the result away, they return None.

>>>> def ng():
> 	return n() + g()
>
>>>> ng()
>
> Traceback (most recent call last):
>    File "<pyshell#14>", line 1, in <module>
>      ng()
>    File "<pyshell#13>", line 2, in ng
>      return n() + g()
> TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'
>

The attempt in ng to add None to None then produce the exception you are 
seeing.

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


Thread

unsupported operand type(s) python v2.7 ngangsia akumbo <ngangsia@gmail.com> - 2015-10-20 01:44 -0700
  Re: unsupported operand type(s) python v2.7 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-10-20 11:00 +0200
    Re: unsupported operand type(s) python v2.7 ngangsia akumbo <ngangsia@gmail.com> - 2015-10-20 02:08 -0700
      Re: unsupported operand type(s) python v2.7 ngangsia akumbo <ngangsia@gmail.com> - 2015-10-20 02:13 -0700

csiph-web