How to obtain the public ip address of the current EC2 instance  in python ?
If you are already using boto you can also use the boto.utils.get_instance_metadata function.  This makes the call to the metadata server, gathers all of the metadata and returns it as a Python dictionary.  It also handles retries.
How to get the public ip of current ec2 instance in python?