View Single Post
Old Dec 7th, 2006, 10:32 AM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by m0rb1d View Post
So, (num) get it's value from my_abs(a), whereas the function my_abs(num) would become my_abs(a).

Sometimes I get stuck on stupid, apologies.
I've found that most newcomers to programmers have a lot of difficulty with the concept of functions, particularly with how parameters are passed to functions. So to actually grasp the essence of functions so quickly is far from stupid.

Quote:
Originally Posted by sixstringartist
Now Im not sure if Python is different so correct me if Im wrong, but in C, my_abs would not really get the variable a, in a way that it can be altered. It only gets the value of a to use. You would have to pass the function a pointer to a if you wanted to directly alter the value of a inside the function.
Don't confuse him

In Python, all variables are references, but due to Python's shallow learning curve, you don't really need to know about this until you start dealing with objects and mutable data structures. So one step at a time.
Arevos is offline   Reply With Quote