It seems that atomic types (int, string, ...) are passed by value, and all others (objects, pointers to functions, pointers to methods, ...) are passed by reference.
What is the best way to check if a variable will be passed by value or by reference?
isinstance(input_, float) or isinstance(input_, basestring) or <...>
seems to be very inelegant.
The reason why I need it is below: I have a class that wraps wx.Button, if args/kwargs are of types that are passed by value, updating their values in other objects will not be taken into account. So some checks will be beneficial
class PalpyButton(wx.Button):
def __init__(self, parent, btnLabel, handler, successMsg = None, args = (), kwargs = {}):
super(PalpyButton, self).__init__(parent, -1, btnLabel)
self.handler = handler
self.successMsg = successMsg
parent.Bind(wx.EVT_BUTTON, lambda event: self.onClick(event, *args, **kwargs), self)
def onClick(self, event, *args, **kwargs):
try:
self.handler(*args, **kwargs)
if self.successMsg != None:
if hasattr(self.successMsg, '__call__'):
showInfoMessageBox(self.successMsg())
else:
showInfoMessageBox(self.successMsg)
except BaseException, detail:
showErrorMessageBox(detail)