def create_container(swift_connection, name, storage_policy=None):
    """
    Create a container with an optional storage policy.

    :param swift_connection: connection to Swift
    :type swift_connection: :py:class:`swiftclient.client.Connection`
    :param name: container name
    :type name: string
    :param storage_policy: container storage policy (optional)
    :type storage_policy: string
    :return: policy of the craeted container
    """
    headers = {'X-Storage-Policy': storage_policy} if storage_policy else {}
    swift_connection.put_container(name, headers)
    return swift_connection.head_container(name).get('x-storage-policy')