Python works differently from languages that support passing arguments by reference or by value. Function arguments become local variables assigned to each value that was passed to the function. But this doesn’t prevent you from achieving the same results you’d expect when passing arguments by reference in other languages.
In this course, you learned:
- How Python handles assigning values to variables
- How function arguments are passed by assignment in Python
- Why returning values is a best practice for replicating pass by reference
- How to use attributes, dictionaries, and lists as alternative best practices
For more information on concepts covered in this lesson, you can check out:
- The Walrus Operator: Python 3.8 Assignment Expressions | Real Python Tutorial
- Immutability in Python | Real Python Video Course
- Namespaces and Scope in Python | Real Python Tutorial
- Python Scope & the LEGB Rule: Resolving Names in Your Code | Real Python Tutorial
- Python Constants: Improve Your Code’s Maintainability
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
mckown on Nov. 9, 2021
Just when I thought Halloween was over. Wait! What?
How many of us were swayed to try Python because of its simple syntax, easy-to-use REPL, and seductive lists vs limited arrays? Like high schoolers wandering into that empty, dark house.
I should have hesitated when I learned that there are no private variables. Nothing is private in Python. I should have run when I found that variables can be assigned any type willy-nilly. Strong data types are non-existent in Python. But I stayed. And, now, despite all the years of learning pass by reference and pass by value–common concepts that every American child learns by heart, the demons arise to sweep all that away to pass by assignment. It makes one’s hackles rise.
There are too many plots and subplots in this course. Can you make it through without having your programmer’s blood sucked out with every “AHA” moment. This course is good. SCARY good.
I’m looking forward to Howard Francis’ (and team!) next spooktacular installment.... If I ever recover my soul.