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

noreply@sourceforge.net noreply@sourceforge.net
Tue, 07 Aug 2001 10:37:17 -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.

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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-08-07 10:37

Message:
Logged In: YES 
user_id=6380

Well, that would be a very generous API -- probably too
generous. I'm tempted to allow only a single argument with a
mapping interface -- that would be more in line with how
tuple() and list() work.  Let this also be a reminder for me
to fix the docstring when I fix the constructor.

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

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