C++ vs. Python API Discrepancies has been edited by Jonathan Robie (Mar 09, 2009).

(View changes)

Content:

This page compares C++ and Python code samples from our examples, looking for arbitrary discrepancies in the API. I suggest that we add proposals to fix these discrepancies inline for each example.

Opening and closing connections and sessions

C++

 
Connection connection;
try {
    connection.open(host, port);
    Session session =  connection.newSession();
    ...
    connection.close();
    return 0;
} catch(const std::exception& error) {
    std::cout << error.what() << std::endl;
}
return 1;

Python

 
host="127.0.0.1"
port=5672
user="guest"
password="guest"

socket = connect(host, port)
connection = Connection (sock=socket, username=user, password=password)
connection.start()
session = connection.session(str(uuid4()))
...
session.close(timeout=10)

Discrepancies

  • Python uses a socket object, not needed in the C++ API. I suggest that Python follow C++ here.
  • Python requires the user to provide a UUID instead of creating one for him. I suggest that Python provide the UUID automagically, as does C++.
  • Our Python examples end by closing the session, our C++ examples end by closing the connection. If both APIs allow both approaches, we should fix the examples; if not, we should make the APIs consistent.

--------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[email protected]

Reply via email to