def setenv(foo):
    env.hosts = ['myhost']

def mycmd(foo):
    setenv(foo)
print('env.hosts inside mycmd: %s' % env.hosts)
run('ls')
How can I properly set the `env.hosts` in a function in my Python Fabric `fabfile.py`?