changing a value of a variable

ameoba ahmebah at hotmail.com
Wed Jan 30 11:13:39 EST 2002


marcinm at finisar.com (Marcin Matuszkiewicz) wrote in 
news:dbaf973c.0201291630.273edb44 at posting.google.com:

> How to write a python program that accomplishes the same thing as the
> C program below.
>
> void assign(int *x)
> {
>   *x = 1;
> }


The main reason for doing things like this in C is to return multiple 
values from a function, which in Python can easily be done by returning 
tuples and using tuple assignment.


void assign(int x, int *arga, int *argb)
{
   *arga = x;
   *argb = x;
}


assign(y, &a, &b)


does the same as...

def assign(x):
    return (x,x)


(a, b) = assign(y)



More information about the Python-list mailing list