Newbie: raw_input and other input methods

Carel Fellinger cfelling at iae.nl
Sat Nov 27 23:12:57 CET 1999


Carel Fellinger <cfelling at iae.nl> wrote:

I was to quick, or actually I changed something during posting.

> class Var:
>     '''(environment) variable to be evaluated during prompting'''
>     def __init__(self, var, dict=os.environ):
> 	self.var, self.dict = var, dict

>     def __str__(self):
> 	return self.dict[self.var]

this should read:

        return str(self.dict[self.var])

and now we can do

> if __name__ == '__main__':
      ...
     prompt.nr = Var('nr', locals())
     nr = 0
     while 1:
 	nr = nr + 1
 	print raw_input(prompt)

-- 
groetjes, carel




More information about the Python-list mailing list