osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can global variable be passed into Python function?


Chris Angelico <rosuav at gmail.com>:
> That's the exact line of thinking that leads to problems. You are not
> placing a number at the address "xyz", you are pointing the name "xyz"
> to the number 3. That number still exists elsewhere.

And?

In C, I can say:

   Number *o = malloc(sizeof *o);
   o->value = 3;

Your statement is valid: the number 3 resides elsewhere than the
variable o.

As for Python, there's nothing in the Python specification that would
prevent you from having, say, 63-bit integers as representing
themselves. IOW, you could physically place such integers as themselves
as the reference and the number would not physically exist elsewhere.

Bottom line, there's no fundamental difference between C and Python
variables.


Marko