osdir.com


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

Can global variable be passed into Python function?


On 24/02/2014 18:05, j.e.haque at gmail.com wrote:
> On Sunday, February 23, 2014 5:01:25 AM UTC-6, Marko Rauhamaa wrote:
>> 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.
>
> typedef struct {
>    int value;
> } Number;
>
>    Number *o;
>    o = malloc(sizeof(*o));
>    o->value=3;
>    printf("o<%p>, o->value<%p>\n", o, &o->value);
>
> o<0x9fe5008>, o->value<0x9fe5008>
>
> Is the compiler borked?
>

I can't be bothered to check.  OTOH google groups is so please read and 
action this https://wiki.python.org/moin/GoogleGroupsPython, thanks.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com