I want to verify if a table exist, if exist I want to show a message "Table already exist" and ask again user to enter a new name for table.
But when user enter a table name that already exist, Im getting only the message "Table already exist" but its not asking again to enter the name for the table.
Do you know why its not working?
def validField(info):
field = ""
while not field:
field = raw_input(info)
if not field:
print "Empty field"
return field
def createTable():
tableName = validField("Please enter the name for table: ")
try:
verifyTable = test.get_table(tableName)
except BotoServerError:
print "Table already exist"
tableName = validField("Please enter the name for table: ")
How about:
def createTable():
ok = False
while not ok:
try:
verifyTable = test.get_table(raw_input("Please enter the name for table: "))
ok = True
except BotoServerError:
print "Table already exist"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.