[Tutor] about the function
Brian van den Broek
bvande at po-box.mcgill.ca
Mon Oct 25 01:20:19 CEST 2004
Lin Jin said unto the world upon 2004-10-24 18:58:
> i am new in python.just learn how to defining the function.i want to
> know that if i define three functions.how can i use read the data from
> one function to the other funtion.it;s like if i have function
> draw(pic),setposition(position,pic).if i want to used the data in
> setposition for the draw.how i could do that.
>
> _________________________________________________________________
> Ãâ·ÑÏÂÔØ MSN Explorer: http://explorer.msn.com/lccn/
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
Hi Lin Jin,
I am not sure I understand your question. But this silly example might
be helpful:
def get_the_number_2():
return 2
def get_the_number_3():
return 3
def multiply_two_numbers(x, y):
return x * y
print multiply_two_numbers(get_the_number_2(), get_the_number_3())
>>>
6
So, one way is to use a call to one function in the argument place of
another.
You could also do:
first_arg = get_the_number_2()
second_arg = get_the_number_3()
multiply_two_numbers(first_arg, second_arg)
Are these techniques the sort of thing you were wanting?
One other thing: it is much easier to read a post if a space follows
each period. Like that. :-)
Best,
Brian vdB
More information about the Tutor
mailing list