Replies: 1 comment
-
There's no thing as 'pass by reference' (nor 'pass by value' for that matter) in Python, those are concepts from other languages. Lots of good explanations here: https://stackoverflow.com/questions/986006/how-do-i-pass-a-variable-by-reference |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm trying to organize my micropython code. My first thought was to extract chunks of code into functions and put them in other files. I planned to use import to bring in the function and then run the function. I also planned to use pass by reference so that those functions in other modules could alter things in my main script. However, it doesn't appear to be working. What am I doing wrong?
ref_test_mod.py
main.py
I expected to get the following printouts:
This line is for test <- From main.py
This line is for test <- From ref_test function printing the input string
Override <- From ref_test function now that it's overridden the input string
Override <- From main.py now that ref_test has overridden the original string that was passed by reference
Instead I get this:
This line is for test
This line is for test
Override
This line is for test
Thanks,
Justin
Beta Was this translation helpful? Give feedback.
All reactions