return from function
Denis McMahon
denismfmcmahon at gmail.com
Tue Dec 22 09:23:33 EST 2015
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 at gmail.com
More information about the Python-list
mailing list