[Python-bugs-list] [ python-Bugs-443762 ] dictionary type ignores argument list

noreply@sourceforge.net noreply@sourceforge.net
Mon, 23 Jul 2001 04:07:01 -0700


Bugs item #443762, was opened at 2001-07-23 04:07
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=443762&group_id=5470

Category: type/class unification
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Duncan Booth (duncanb)
Assigned to: Guido van Rossum (gvanrossum)
Summary: dictionary type ignores argument list

Initial Comment:
In 2.2a1 the dictionary type object completely ignores 
its argument list when constructing a new dictionary. 
It always returns an empty dictionary no matter what 
arguments are specified.

Either: it should check that it has been called with 
no arguments.

Or: it should take some arguments and do something 
useful with them.

I would suggest that the following arguments would be 
useful:
dictionary() should return a new empty dictionary.
dictionary(d) where d is a dictionary should return a 
copy of the original dictionary.
dictionary(k1=v1, k2=v2, k3=v3, ...) should return a 
dictionary with keys k1, k2, k3, ... and corresponding 
values.
dictionary(kvlist) where kvlist is a list of key, 
value tuples should build a dictionary from the key 
value pairs (effectively this is the inverse of d.items
()).
dictionary(kseq, vseq) should do the same as dictionary
(zip(kseq, vseq)) i.e. create a dictionary initialised 
with corresponding elements from each list as key and 
value.
Any other arguments to dictionary should be rejected.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=443762&group_id=5470