Why does `hostname` return "dserodio" and not "dserodio.local"? When I run hostname it returns dserodio instead of dserodio.local, which causes problems with Python servers.

I can run sudo hostname dserodio.local but I have to set it again after rebooting.

How can I make it the hostname dserodio.local definitively?
I think you need this:
    sudo scutil –-set HostName dserodio.local

The command that you are running is temporary.
Source
http://osxdaily.com/2010/09/06/change-your-mac-hostname-via-terminal/