Movatterモバイル変換


[0]ホーム

URL:


[Python-ideas] Another use case for the 'lazy' (aka 'delayed') keyword

Michel Desmoulindesmoulinmichel at gmail.com
Tue Feb 28 10:28:34 EST 2017


Only if "None" is not a proper value from .get().And this doest solve the problems with more general callbacks that arenot trying to get a value (cf Django lazy_gettext).Besides, "??" does not exist yet for Python, so let's counter theargument for lazy with the potential benefits of something we don't haveATM.A proposal is already hard enough to defenD on Python-ideas :)Le 28/02/2017 à 16:21, Mark E. Haase a écrit :> This could be solved with a null-coalescing operator, e.g. PEP-505.>>    >>> val = conf.get('setting_name') ?? load_from_db('setting_name')>> The right side isn't evaluated unless the left side is None. It's> similar to this:>>    >>> val = conf.get('setting_name') or load_from_db('setting_name')>> Except that using "or" would result in any false-y value (0, "", [],> etc.) being overridden by the result of `load_from_db(...)`.>> I'm not strongly opposed to "lazy", but I think null-coalescing is> easier to reason about.>


More information about the Python-ideasmailing list

[8]ページ先頭

©2009-2026 Movatter.jp