[Yum] more about: passing two or more variables from a python routine.
Rick Graves
gravesricharde at yahoo.com
Tue Sep 28 19:45:36 UTC 2004
Robert,
The subroutine can pass back expressions -- they do
not have to be reduced to variables.
So the last line of the subroutine could be:
return expr1, expr2, ...
Rick
--- Rick Graves <gravesricharde at yahoo.com> wrote:
> Date: Tue, 28 Sep 2004 12:02:52 -0700 (PDT)
> From: Rick Graves <gravesricharde at yahoo.com>
> Subject: Re: passing two or more variables from a
> python routine.
> To: yum at lists.dulug.duke.edu
>
> Robert,
>
> You wrote:
>
> > ... but I don't know how
> > to return two variables from one subroutine
> fragment
> in python.
> > Probably very simply.
>
>
> In case no one has addressed this yet, you are
> right.
> (I am just a python newbie, but I know the answer to
> that one.)
>
> In the subroutine, the last line should be like
> this:
>
> return Svar1, Svar2
>
> And the call in the calling routine should be:
>
> Cvar1, Cvar2 = subroutine( args )
>
> BTW, the variables can have exactly the same names
> in
> the calling routine and subroutine, but this is not
> a
> requirement. So this would be OK in the subroutine:
>
> return var1, var2
>
> And this would be OK in the calling routine:
>
> var1, var2 = subroutine( args )
>
> I do not know the limit to the number of variables
> you
> can pass, but it is surely big. The value coming
> out
> of the subroutine is really a tuple, which is
> automatically unpacked in the calling routine. And
> the values coming out can be of different types.
> The
> number of targets and the number coming out must
> match, however.
>
> I do not know how it could be any more simple than
> that!
>
> Rick Graves
> (python newbie)
>
>
> --- yum-request at lists.dulug.duke.edu wrote:
>
>
> > Message: 5
> > Date: Tue, 28 Sep 2004 12:21:56 -0400 (EDT)
> > From: "Robert G. Brown" <rgb at phy.duke.edu>
> > Subject: [Yum] distribution variable works...
> > To: "Yellowdog Updater, Modified"
> <yum at lists.dulug.duke.edu>
> > Message-ID:
> >
>
<Pine.LNX.4.44.0409281138170.20382-100000 at lucifer.rgb.private.net>
> > Content-Type: TEXT/PLAIN; charset=US-ASCII
> >
> > On Tue, 28 Sep 2004, Robert G. Brown wrote:
> >
> > The following (2.0.7 derived) config.py actually
> works and does the
> > substitutions and everything. It isn't efficient
> -
> both variables
> > could
> > be set with one set of rpm.TransactionSet() calls,
> but I don't know how
> > to return two variables from one subroutine
> fragment
> in python.
> > Probably very simply.
> >
> >
>
>
More information about the Yum
mailing list