Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78567
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'parameter': 0.09; 'prefix': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Function': 0.09; 'python': 0.11; 'def': 0.12; 'expected)': 0.16; 'expected):': 0.16; 'message- id:@post.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'thanks,': 0.17; 'print': 0.22; 'header:User-Agent:1': 0.23; 'fine': 0.24; 'defined': 0.27; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'getting': 0.31; 'prints': 0.31; 'alone': 0.33; 'test': 0.35; 'charset:us-ascii': 0.36; 'hi,': 0.36; 'expected': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'below:': 0.68; 'below.': 0.71; 'received:2': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Shiva <shivaji_tn@yahoo.com> |
| Subject | Function passed as an argument returns none |
| Date | Wed, 1 Oct 2014 22:37:13 +0000 (UTC) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | sea.gmane.org |
| User-Agent | Loom/3.14 (http://gmane.org/) |
| X-Loom-IP | 2.29.232.170 (Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0) |
| 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.14532.1412203048.18130.python-list@python.org> (permalink) |
| Lines | 41 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1412203048 news.xs4all.nl 2894 [2001:888:2000:d::a6]:45626 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Bytes | 3448 |
| X-Received-Body-CRC | 2543929831 |
| Xref | csiph.com comp.lang.python:78567 |
Show key headers only | View raw
Hi,
I am learning Python (version 3.4) strings.I have a function that takes in a
parameter and prints it out as given below.
def donuts(count):
if count <= 5:
print('Number of donuts: ',count)
else:
print('Number of donuts: many')
return
It works fine if I call
donuts(5)
It returns:
we have 5 DN (as expected)
However if I do :
test(donuts(4), 'Number of donuts: 4')
where test is defined as below:
def test(got, expected):
print('got: ', got, 'Expected:' ,expected)
if got == expected:
prefix = ' OK '
else:
prefix = ' X '
print (('%s got: %s expected: %s') % (prefix, repr(got), repr(expected)))
Only 'None' gets passed on to parameter 'got' instead of the expected value
of 4.
Any idea why 'None' is getting passed even though calling the donuts(4)
alone returns the expected value?
Thanks,
Shiva.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Function passed as an argument returns none Shiva <shivaji_tn@yahoo.com> - 2014-10-01 22:37 +0000
Re: Function passed as an argument returns none Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-02 00:23 +0000
Re: Function passed as an argument returns none Rustom Mody <rustompmody@gmail.com> - 2014-10-01 19:29 -0700
Re: Function passed as an argument returns none Chris Angelico <rosuav@gmail.com> - 2014-10-02 14:02 +1000
Re: Function passed as an argument returns none Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-02 17:59 +1000
Re: Function passed as an argument returns none cl@isbd.net - 2014-10-02 10:43 +0100
Re: Function passed as an argument returns none Rustom Mody <rustompmody@gmail.com> - 2014-10-02 04:30 -0700
Re: Function passed as an argument returns none Rustom Mody <rustompmody@gmail.com> - 2014-10-02 04:38 -0700
Re: Function passed as an argument returns none Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-03 10:10 +1000
Re: Function passed as an argument returns none Rustom Mody <rustompmody@gmail.com> - 2014-10-02 18:49 -0700
Re: Function passed as an argument returns none Chris Angelico <rosuav@gmail.com> - 2014-10-03 12:08 +1000
csiph-web