On 28/07/2023 17:59, Hugo Dos Santos wrote:
Hi Hugo,
> I try to retrieve all the DNS fields of a domain name using the DNS package
> on python.
>
> I found on the doc the code for retrive one field :
>
> import dns.resolver
Here, you're importing the "dns" module. So far so good.
Here, you're using the "from_text" function of the
dns.name module.
> dns = dns.resolver.resolve(n,'ns')
Boom! Here you're overwriting the "dns" module namespace with a new
variable. So in effect, you're unloading the entire "dns" module.
[snip]
> I have this error :
>
> n = dns.name.from_text('
google.fr')
> ^^^^^^^^^^^^^^^^^^
> AttributeError: 'Name' object has no attribute 'from_text'. Did you mean:
> 'to_text'?
This is because you overwrote the dnspython "dns" module with a new
variable altogether. You need to use other variable names.
I don't know whether to call this a feature or bug of python, but it's
not the first time someone has made this mistake.
Regards,
Anand