Floris wrote:
> FWIW having spaces between the function name and parentheses is rather
>uncommon for python style. Though of course complaining about style
>without using an auto-formatter is pretty meh these days :)
>
Yeah fair enough, it's the default in the C code, but we pretty
clearly have different styles going on in different languages.
>> + val_p = capi.lib.notmuch_config_pairs_value (super()._iter_p)
>> + key_p = capi.lib.notmuch_config_pairs_key (super()._iter_p)
>> + key = base.BinString.from_cffi(key_p)
>
>does key_p need a NULL check first or can it never be NULL?
I think it can never be NULL, but if it is, better to raise an exception I
think.
>> def test_iter(self, db):
>> - assert list(db.config) == []
>> - db.config['spam'] = 'ham'
>> - db.config['eggs'] = 'bacon'
>> - assert set(db.config) == {'spam', 'eggs'}
>> - assert set(db.config.keys()) == {'spam', 'eggs'}
>> - assert set(db.config.values()) == {'ham', 'bacon'}
>> - assert set(db.config.items()) == {('spam', 'ham'), ('eggs',
>> 'bacon')}
>> + import re
>> + prefix = re.compile(r"^TEST[.]")
>> + assert [ x for x in list(db.config) if prefix.match(x) ] == []
>
>`x.startswith('TEST.')` is probably lighter weight here, maybe easier to
>read too that's subjective i guess
>
>You can even try something like this to further make it more readable:
>
>has_prefix = lambda x: x.startswith('TEST.')
I did variation on this, defining an inner function instead of using a lambda.
>
>> + db.config['TEST.spam'] = 'TEST.ham'
>> + db.config['TEST.eggs'] = 'TEST.bacon'
>> + assert { x for x in set(db.config) if prefix.match(x) } ==
>> {'TEST.spam', 'TEST.eggs'}
>> + assert { x for x in set(db.config.keys()) if prefix.match (x) } ==
>> {'TEST.spam', 'TEST.eggs'}
>
>I'm not sure why you need to wrap `db.config.keys()` in `set()`? This
>explicitly creates a set out of things before turning it back into an
>interator while you're fine with the original iterator I think?
Good question. That seems to apply to list(db.config) above also?
_______________________________________________
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]