[Python-ideas] adding dictionaries
Ron Adam
ron3200 at gmail.com
Wed Jul 30 16:27:00 CEST 2014
More information about the Python-ideas mailing list
Wed Jul 30 16:27:00 CEST 2014
- Previous message: [Python-ideas] adding dictionaries
- Next message: [Python-ideas] adding dictionaries
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 07/29/2014 07:17 PM, Steven D'Aprano wrote:
> On Tue, Jul 29, 2014 at 06:12:16PM -0500, Ron Adam wrote on the
> similarity of lists and dicts:
>
> [...]
>> >Well, here is how they currently compare.
>> >
>>>>> > >>>set(dir(dict)).intersection(set(dir(list)))
>> >{'copy', '__hash__', '__format__', '__sizeof__', '__ge__', '__delitem__',
>> >'__getitem__', '__dir__', 'pop', '__gt__', '__repr__', '__init__',
>> >'__subclasshook__', '__eq__', 'clear', '__len__', '__str__', '__le__',
>> >'__new__', '__reduce_ex__', '__doc__', '__getattribute__', '__ne__',
>> >'__reduce__', '__contains__', '__delattr__', '__class__', '__lt__',
>> >'__setattr__', '__setitem__', '__iter__'}
> Now strip out the methods which are common to pretty much all objects,
> in other words just look at the ones which are common to mapping and
> sequence APIs but not to objects in general:
>
> {'copy', '__ge__', '__delitem__', '__getitem__', 'pop', '__gt__',
> 'clear', '__len__', '__le__', '__contains__', '__lt__', '__setitem__',
> '__iter__'}
>
> And now look a little more closely:
>
> - although dicts and lists both support order comparisons like > and <,
> you cannot compare a dict to a list in Python 3;
I think this would be the case we are describing with + and +=. You would
not be able to add a dict and some other incompatible type.
Cheers,
Ron
- Previous message: [Python-ideas] adding dictionaries
- Next message: [Python-ideas] adding dictionaries
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list