Can global variable be passed into Python function?

j.e.haque at gmail.com j.e.haque at gmail.com
Mon Feb 24 19:05:49 CET 2014


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?




More information about the Python-list mailing list