Re: C++, Python: Common Includes

2009-02-12 Thread Joshua Kramer


Every Python example currently has the same template, with a clearly marked 
section for the code that differs from other examples. I did that on purpose 
when I did the first set of examples ;-


If that's the RedHat documentation you're referring to... my script 
skeleton is actually based off of that.  Mine also includes other 
utilitarian things such as logging setup, forking and disconnecting from 
the terminal (daemonization, etc) that I 'liberated' from the Python 
Cookbook.


But I'd be happy to share if anybody's interested.  :)

Cheers,
-Josh

--

-
http://www.globalherald.net/jb01
GlobalHerald.NET, the Smarter Social Network! (tm)

-
Apache Qpid - AMQP Messaging Implementation
Project:  http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org



Re: C++, Python: Common Includes

2009-02-11 Thread Rafael Schloming

Jonathan Robie wrote:

 From our sample programs:

C++:

#include qpid/client/Connection.h
#include qpid/client/Session.h
using namespace qpid::client;
using namespace qpid::framing;

Python:

import qpid
import sys
import os
from qpid.util import connect
from qpid.connection import Connection
from qpid.datatypes import Message, RangedSet, uuid4
from qpid.queue import Empty

To me, the C++ is clean and easy to remember. To me, the Python is 
cluttered, and I have to look it up each time. In general, if I import a 
class, I don't want to have to ask what else do I need to import if I 
want to be able to use the class I just imported?


In Python, couldn't the user just import a Connection class and a 
Session class, and we could design the API so that they get what they 
need to use those classes automagically?  Or is there a pythonic reason 
to do it this way?


This isn't really an apples to apples comparison. You can do * imports 
in python as well, it's just considered better style to actually list 
out what you're importing:


from qpid.connection import *
from qpid.datatypes import *
from qpid.util import *
from qpid.queue import *

--Rafael




-
Apache Qpid - AMQP Messaging Implementation
Project:  http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org