[C++-sig] Arbitrary argument lists, Python style?

Conan Brink conanb at STCG.net
Mon Jul 28 21:34:01 CEST 2003


Forgive me if I'm just being dense, but in hours of searching multiple
archives, I have not been able to find a way to implement the following
Python code in C++ via BPL (simplified somewhat for purposes of this
discussion):

 

class BackCaller:

  def SetCallback(self, action, *args):

    self.cb = (action, args)

 

  def CallItBack(self):

    if self.cb:

      (action, args) = self.cb

      return action(*args)

 

The thing that's causing me to pull foot-long hairs from my head is that
little *args

 

Is such a thing possible, or do I need to do one of the following:

1)                            Tell my Python users that they have to
explicitly wrap their args in a tuple?

2)                            Write a Python wrapper that does the
translation back and forth between the variable arg list and a tuple
that can be passed explicitly to and from my BPL-wrapped class?

 

(and no, I'm not just doing this for fun - I've got some existing Python
code that is being redone in C++ because it needs to live closer to the
wire)

 

-Conan




This message contains information that may be confidential and privileged.  Unless you are the addressee (or authorized to receive messages for the addressee), you may not use, copy, or disclose to anyone the message or any information contained in the message.  If you have received the message in error, please advise the sender by reply e-mail and delete the message.  Nothing in this message should be interpreted as a digital or electronic signature that can be used to authenticate a contract or any other legal document.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20030728/64a4ef0f/attachment.htm>


More information about the Cplusplus-sig mailing list