Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100728
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Denis McMahon <denismfmcmahon@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: return from function |
| Date | Tue, 22 Dec 2015 14:23:33 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 30 |
| Message-ID | <n5bmd5$v26$2@dont-email.me> (permalink) |
| References | <mailman.22.1450699272.2237.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Tue, 22 Dec 2015 14:23:33 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="66ffcfa4470a58bcddbdcd1913f98ab4"; logging-data="31814"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19weSJc0M8KSNOtMqwB0x6y/kx4il/RkUE=" |
| User-Agent | Pan/0.136 (I'm far too busy being delicious; GIT 926a150 git://git.gnome.org/pan2) |
| Cancel-Lock | sha1:XfN2fezz3NEBCk0qesTD7jvvI7I= |
| Xref | csiph.com comp.lang.python:100728 |
Show key headers only | View raw
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