Passing arguments to function - (The fundamentals are confusing me)
Christopher Subich
spam.csubich+block at block.subich.spam.com
Tue Aug 9 16:11:28 EDT 2005
Gregory Piñero wrote:
> So what if I do want to share a boolean variable like so:
Well, the easiest way is to wrap it in a list:
mybool = [True]
mybool[0] = False
mybool[0] = True
and so on.
Alternately, what is this boolean attached to that's so significant?
Sharing an arbitrary boolean, without any context, is rather strange --
perhaps it would be best to include both the boolean and associated
context in a single, larger object.
Also, remember that Python functions can return more than one value,
through implicit tuple packing and unpacking. This greatly reduces the
need for C-like result = function(&other_result) - isms.
def myfunc():
return 1,2,3
(a,b,c) = myfunc()
a == 1
b == 2
c == 3
More information about the Python-list
mailing list