Is there a method to pass a variable number of arguments to a function and have it change those arguments using the ( *args, **keywords )
style of argument passing? I've tried a few things but either see no change or have an error raised by the compiler:
def foo( *args ):
args[0] = 4
This gets me TypeError: object does not support assignment
(they're tuples.) Or
def foo( *args ):
plusOne = [ item+1 for item in args ]
args = plusOne
which has no effect what so ever. If there is no mechanism nor work around I can admit defeat.
Edit:
To clarify why I'm trying to go this route, consider the case here:
class bar(object):
def __init__(self,obj):
self.obj = obj
def foo( input ):
input.obj = "something else"
If I pass my bar
object into foo, I get a change in the state. To create a decorator which performs a deepcopy
which resets all such state I'm currently customizing it for N arguments. I'd like to create one which accepts any number of arguments. Hence, the question.