Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes: > On Tue 2017-11-28 23:46:11 +0100, Ruben Pollan wrote: >> Message.get_property (prop) returns a string with the value of the property and >> Message.get_properties (prop, exact=False) returns a list [(key, value)] > > This looks like a sensible approach to me. I'd be curious to hear what > others think of this. > > In considering the API design space here, it occurs to me that it might > be more pythonic for get_properties to return a dict like: I would probably model properties as a dictionary in notdb, making this a collections.abc.MutableMapping implementation with a .get_all(prop) method inspired from the stdlib email.message package. This kind of also implies making properties access a property rather then a method call: msg.properties['prop'] = 'foo' msg.properties['prop'] = 'bar' msg.properties['prop'] == 'foo' # pot luck msg.properties.get_all('prop') == {'foo', 'bar'} # properties are unsorted are they? This also has the binary question problem, is this returned as bytes or as str? Current Python bindings seem to go for .decode('utf-8', errors='ignore') afaik which is somewhat lossy. Cheers, Floris _______________________________________________ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch