Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79895

What does %%(%s)s mean/expand to in Python? What does rowshtml += (rowhtml % ((fieldname, ) * 3)) expand to? Kindly explain.

Newsgroups comp.lang.python
Date 2014-10-28 23:15 -0700
Message-ID <ee27d38d-8732-485c-a64b-0da2eee1d93b@googlegroups.com> (permalink)
Subject What does %%(%s)s mean/expand to in Python? What does rowshtml += (rowhtml % ((fieldname, ) * 3)) expand to? Kindly explain.
From satishmlmlml@gmail.com

Show all headers | View raw


def fetchRecord(db, form): 
 try: 
  key = form['key'].value 
  record = db[key] 
  fields = record.__dict__ 
  fields['key'] = key 
 except: 
  fields = dict.fromkeys(fieldnames, '?') 
  fields['key'] = 'Missing or invalid key!' 
 return fields 
def updateRecord(db, form): 
 if not 'key' in form: 
  fields = dict.fromkeys(fieldnames, '?') 
  fields['key'] = 'Missing key input!' 
 else: 
  key = form['key'].value 
  if key in db: 
   record = db[key] 
 else: 
   from person import Person 
   record = Person(name='?', age='?') 
 for field in fieldnames: 
   setattr(record, field, eval(form[field].value)) 
  db[key] = record 
  fields = record.__dict__ 
  fields['key'] = key 
 return fields 
db  =  shelve.open(shelvename) 
action = form['action'].value if 'action' in form else None 
if action == 'Fetch': 
 fields = fetchRecord(db, form) 
elif action == 'Update': 
 fields = updateRecord(db, form) 
else: 
 fields = dict.fromkeys(fieldnames, '?') 
 fields['key'] = 'Missing or invalid action!' 
db.close() 
print(replyhtml % htmlize(fields)) 

What does %%(%s)s mean in Python? 

also 
what does 
rowshtml += (rowhtml % ((fieldname,) * 3)) expand to? 

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

What does %%(%s)s mean/expand to in Python? What does rowshtml += (rowhtml % ((fieldname, ) * 3)) expand to? Kindly explain. satishmlmlml@gmail.com - 2014-10-28 23:15 -0700
  Re: What does %%(%s)s mean/expand to in Python? What does rowshtml += (rowhtml % ((fieldname, ) * 3)) expand to? Kindly explain. Peter Otten <__peter__@web.de> - 2014-10-29 08:42 +0100
  Re: What does %%(%s)s mean/expand to in Python? What does rowshtml += (rowhtml % ((fieldname, ) * 3)) expand to? Kindly explain. Christian Gollwitzer <auriocus@gmx.de> - 2014-10-29 09:13 +0100

csiph-web