In Ansible 1.1 and earlier this is a little tricky to do. You can't in-line Python code in playbooks like you can in templates. But the good news is, a few feature in the latest codebase on GitHub (to be released as version 1.2) allows Jinja2-style templating in the playbooks as well! Check this thread out:
https://groups.google.com/forum/#!topic/ansible-project/Gb3ABiEtGtA
So this means you'll be able to do:
--connect-to {{ ' '.join( groups['do'] }}
...right in the playbook if you're using the latest GitHub code.
Hope this helps!