Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97829 > unrolled thread
| Started by | ngangsia akumbo <ngangsia@gmail.com> |
|---|---|
| First post | 2015-10-20 01:44 -0700 |
| Last post | 2015-10-20 02:13 -0700 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.python
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
| From | ngangsia akumbo <ngangsia@gmail.com> |
|---|---|
| Date | 2015-10-20 01:44 -0700 |
| Subject | unsupported operand type(s) python v2.7 |
| Message-ID | <695863e0-7c7b-4739-bbc7-6719e40133fb@googlegroups.com> |
>>> def n():
34 * 2
>>> def g():
4 + 2
>>> 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'
[toc] | [next] | [standalone]
| From | Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> |
|---|---|
| Date | 2015-10-20 11:00 +0200 |
| Message-ID | <mailman.49.1445331653.878.python-list@python.org> |
| In reply to | #97829 |
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.
[toc] | [prev] | [next] | [standalone]
| From | ngangsia akumbo <ngangsia@gmail.com> |
|---|---|
| Date | 2015-10-20 02:08 -0700 |
| Message-ID | <a40a7dc7-f60b-4987-a05b-741b86a8ae6c@googlegroups.com> |
| In reply to | #97830 |
On Tuesday, October 20, 2015 at 10:01:44 AM UTC+1, Wolfgang Maier wrote: > 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. thanks
[toc] | [prev] | [next] | [standalone]
| From | ngangsia akumbo <ngangsia@gmail.com> |
|---|---|
| Date | 2015-10-20 02:13 -0700 |
| Message-ID | <bdb0245e-c29c-49c5-8988-0827262c323c@googlegroups.com> |
| In reply to | #97831 |
On Tuesday, October 20, 2015 at 10:08:51 AM UTC+1, ngangsia akumbo wrote:
> On Tuesday, October 20, 2015 at 10:01:44 AM UTC+1, Wolfgang Maier wrote:
> > 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.
>
> thanks
def n():
return 3 * 2
def g():
return 3+ 6
def ng():
return n()+g()
print ng()
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web