Totally Confused: Passing variables to functions

Dan Bishop danb_83 at
Fri Jun 6 02:21:36 CEST 2003

Chuck <cdreward at> wrote in message news:<m6ptdvg3p8dvcbpg7qhelb7s2i0slrk7b0 at>...
> I've hit a stumbling block while trying to pick up Python. I've googled
> around, and I don't think I'm the first to have this question, but I haven't
> been able to find an answer that explains things for me.

You said you were familiar with C, so I'll try to explain this using C

> def blah(arg):
>     arg.append(3)

is (roughly) equivalent to

void blah(list *arg) {

In general, think of every variable (including function arguments) as
a pointer, and every "." as a "->".

> But it's not [pass-by-reference], because if I say "arg = None" inside the
> function, "v" is unchanged.

void blah(list *arg) {
   arg = NULL;

All Python assignment statements have the semantics of C's "lhs=rhs;"
and NOT "*lhs=*rhs;".

More information about the Python-list mailing list