I also needed to drive the Ansible Python API, and would rather pass hosts as arguments rather than keep an inventory. I used a temporary file to get around Ansible's requirement, which may be helpful to others:
In my case, I did not want to have hosts: all in my playbook, because it would be bad if someone ran the playbook and forgot to include -i 10.254.3.133,