The fully qualified domain name is returned by socket.getfqdn()
.
BUT: it does not do the same as "hostname --fqdn".
There are some hints in the comments of the following question, but I would like to know the canonical answer. How do I get my computer's fully qualified domain name in Python?
How to get the FQDN like hostname --fqdn
does.