|
dict( [mapping-or-sequence])
Return a new dictionary initialized from an optional positional argument or from a set of keyword arguments. If no arguments are given, return a new empty dictionary. If the positional argument is a mapping object, return a dictionary mapping the same keys to the same values as does the mapping object. Otherwise the positional argument must be a sequence, a container that supports iteration, or an iterator object. The elements of the argument must each also be of one of those kinds, and each must in turn contain exactly two objects. The first is used as a key in the new dictionary, and the second as the key's value. If a given key is seen more than once, the last value associated with it is retained in the new dictionary.
If keyword arguments are given, the keywords themselves with their associated values are added as items to the dictionary. If a key is specified both in the positional argument and as a keyword argument, the value associated with the keyword is retained in the dictionary. For example, these all return a dictionary equal to {"one": 2, "two": 3}:
dict({'one': 2, 'two': 3})
dict({'one': 2, 'two': 3}.items())
dict({'one': 2, 'two': 3}.iteritems())
dict(zip(('one', 'two'), (2, 3)))
dict([['two', 3], ['one', 2]])
dict(one=2, two=3)
dict([(['one', 'two'][i-2], i) for i in (2, 3)])
New in version 2.2. Changed in version 2.3: Support for building a dictionary from keyword arguments added.
Add by Pancho
You can edit it here
|
|
Adding comments is available only for registered users.
|
Study Reveals a Secret to the Success of Notorious, Disease-Causing Microbes
A study published in the July 23 issue of Cell identifies the mechanism used by several types of common, virulent microbes to infect plants and cause devastating blights. Microbes using this infection mechanism include fungi that are currently causing wheat rust epidemics in Africa and Asia, and a class of parasitic algae, called oomycetes, that resulted in the Irish potato blight of the 19th Century. These microbes remain an agricultural scourge today. The researchers ...
More at http://www.nsf.gov/news/news_summ.jsp?cntn_id=117036&WT.mc_id=USNSF_51&WT.mc_ev=click
This is an NSF News item.
|
|
PycckaR BepcuR
Articles

Library

Downloads

|