Question re: eval()

Emile van Sebille emile at
Fri Dec 29 15:22:24 EST 2000

I'm still not following.  Will the user be typing in
something that needs specifically to be eval'd?  If so, eval
won't take a UserDict or class.  You may be able to populate
a dictionary by determining the variables in the expression
(see sample below).  Or will it be (or could it be) a
properly formed SQL statement?  Or will they be providing
parameters for information to be accessed, such as a
parameter names and range values?

#--- for simple expressions

def getEvalVars(s, sgVars=None, slVars=None):
    if sgVars == None:
    if slVars == None:
    stillErrors = 1
    newVars = []
    while stillErrors:
            eval(s, sgVars, slVars)
            stillErrors = 0
        except NameError, err:
            stillErrors = 1
            errDesc = str(err)
            missingVar = errDesc.split("'")[-2]
            slVars[missingVar] = 1
            stillErrors = 0
    return newVars

print getEvalVars('these + names + are + missing')


Emile van Sebille
emile at

"Clarence Gardner" <clarence at> wrote in message
news:978118012.3281608 at
> On Fri, 29 Dec 2000, Emile van Sebille wrote:
> >What are you trying to do that using a dict doesn't
> The lazy evaluation.  Not only will the values that I want
to supply
> require large database accesses to retrieve, but I don't
even know
> with what names they will be requested!
> Clarence Gardner
> clarence at

More information about the Python-list mailing list