Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100728
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: return from function |
| Date | 2015-12-22 14:23 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n5bmd5$v26$2@dont-email.me> (permalink) |
| References | <mailman.22.1450699272.2237.python-list@python.org> |
On Sun, 20 Dec 2015 12:34:40 +0000, Emil Natan wrote:
> I'm completely new to Python.
> parent_domain = domainname.partition('.')[2]
> try:
> print('Test for parent domain %s' % parent_domain)
> z = dns.resolver.query(parent_domain, 'SOA')
> print('the parent domain we use is: %s' % parent_domain)
> return parent_domain
> except dns.resolver.NXDOMAIN:
> print('NXDOMAIN: invoke find_parent_domain recursively')
> find_parent_domain(parent_domain)
None is being returned in this case!
> except dns.resolver.NoAnswer:
> print('NoAnswer: invoke find_parent_domain recursively')
> find_parent_domain(parent_domain)
And in this case.
Do you want to return None in the NXDOMAIN and NoAnswer cases? If not, a
return statement might help in returning a value.
When you recurse back into a function you still need to return the result
of the recursion.
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
return from function Emil Natan <shlyoko@gmail.com> - 2015-12-20 12:34 +0000 Re: return from function Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-12-21 12:07 +0000 Re: return from function Denis McMahon <denismfmcmahon@gmail.com> - 2015-12-22 14:23 +0000
csiph-web