return from function
Jon Ribbens
jon+usenet at unequivocal.co.uk
Mon Dec 21 07:07:29 EST 2015
On 2015-12-20, Emil Natan <shlyoko at gmail.com> wrote:
> I have the following function to find the parent for domain. It removes the
> left most label from the name and then checks if SOA record exists for the
> reminder, if not it calls itself recursively removing another label and
> checking again for SOA record. It works well for 'co.uk' and 'amazon.co.uk'
> for example. It does not return the expected value 'uk' when invoked for '
> amazon1.co1.uk', though the print command before the return prints what is
> expected. Can someone explain why? Thanks.
You probably want to look at this: https://publicsuffix.org/
> except dns.resolver.NXDOMAIN:
> print('NXDOMAIN: invoke find_parent_domain recursively')
> find_parent_domain(parent_domain)
return find_parent_domain(parent_domain)
> except dns.resolver.NoAnswer:
> print('NoAnswer: invoke find_parent_domain recursively')
> find_parent_domain(parent_domain)
return find_parent_domain(parent_domain)
More information about the Python-list
mailing list