where is upvar

Harald Kirsch kirschh at lionbioscience.com
Thu Sep 21 09:53:08 CEST 2000

"Jake Baker" <jbaker at ummelec.com> writes:

> Harald Kirsch wrote:
> > def bla(someparams, upvars=local())
> > upvars['parentsVar'] = "some value set in parent stack frame"
> And then later wrote:
> > Not if it is documented and if the sole purpose of a certain function
> > is to do that in a defined way.
> If that is your desire, require the caller to pass you his local():
> def bla ( params, upvars):
>     "Please pass your local() to upvars when calling this function."

> (Although my suspicion is that that's not what you want to do - try

It is exactly what I want, except that it would be even nicer if
locals() could be the default for upvars. That's the idea of defaults,
that they cover the most common case, and I expect locals() to be the
most common case.

> to rethink the problem using Pythons powerful abilities rather than
> trying to fit Python code to what is arguably a cludge in Tcl. If

  Nice rhetoric: it associates (Python, powerful) and (Tcl, clugde).

> you explain your problem, perhaps someone on the list can suggest a
> better way of solving it.)

My entrance into the world of python was to write a command line
parser ala http://wsd.iitb.fhg.de/~kir/clighome/. It is quite natural
to let the parser set variables directly in the calling stack frame,
normally the __main__ of the script.

  Harald Kirsch
Harald Kirsch   | kirschh at lionbioscience.com | We make the tools to
LION Bioscience | +49 6221 4038 172          | reverse engineer nature.

More information about the Python-list mailing list