J. Peng 写道: > Please see the code below,what's the scope for object "name"? > I thought it should be located in the while block, but it seems not > really,it can be accessed out of while (the db[name] statement).Thanks > in advance. > >
sorry the before code seems be disordered,re-posted it. db = {} def newuser(): prompt = 'login desired: ' while 1: name = raw_input(prompt) if db.has_key(name): prompt = 'name taken, try another: ' continue else: break pwd = raw_input('passwd: ') db[name] = pwd -- http://mail.python.org/mailman/listinfo/python-list