List Comprehensions in build Connection String, Step by Step : List Comprehension « List « Python Tutorial






params = {"server":"yourServer", "database":"master", "uid":"sa", "pwd":"secret"} 
print params.items() 
print [k for k, v in params.items()]            
print [v for k, v in params.items()]                 
print ["%s=%s" % (k, v) for k, v in params.items()]








7.15.List Comprehension
7.15.1.List Comprehension
7.15.2.List Comprehensions in build Connection String, Step by Step
7.15.3.Filtering Lists: [mapping-expression for element in source-list if filter-expression]
7.15.4.List Type Operators and List Comprehensions
7.15.5.Extended List Comprehension Syntax
7.15.6.Using List Comprehensions on Files