Asked • 05/05/19

How do I pass a variable by reference?

The Python documentation seems unclear about whether parameters are passed by reference or value, and the following code produces the unchanged value 'Original' class PassByReference:  def __init__(self):   self.variable = 'Original'   self.change(self.variable)   print(self.variable)  def change(self, var):   var = 'Changed'Is there something I can do to pass the variable by actual reference?

1 Expert Answer

By:

Brendan V. answered • 05/08/19

Tutor
New to Wyzant

Math, science, and programming tutor

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.