Take a look here:
 https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/hello_world_vcenter.py#L31
... or if you want ...
  https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/getallvms.py#L68
... which makes use of ...
https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/tools/cli.py#L74