The title is misleading - this has nothing to do with the conditional operator, except small syntactic similarity.
Elazar בתאריך יום ו׳, 25 במאי 2018, 05:40, מאת Jacco van Dorp < j.van.d...@deonet.nl>: > 2018-05-25 14:26 GMT+02:00 Kirill Balunov <kirillbalu...@gmail.com>: > > If it is an expression, what should `do_something if cond` return on > > failure? If you don't care you can already use `cond and do_something`. > > Duh, forgot to mention. > I wouldn't have it return anything. Ternary returns something because > you have two options and picks one. This is conditional execution of a > statement. I guess it would be a statement, like normal if. > > I guess cond and do_something would be equivalent, but that's not > really the intention of and/or, no matter how much it's used for this > sort of thing. > > Disclaimer: > I don't really expect this to be accepted. It's more of a minor gripe > i've occasionally had. This afternoon, I wrote: > > if not article["art_wt"]: article["art_wt"] = 0 > if not article["px_pchs"]: article["px_pchs"] = 0 > if not article["px_calc"]: article["px_calc"] = 0 > if not article["px_sell"]: article["px_sell"] = 0 > > while preparing a dict for import in accountview. I try not to make a > habit of dismissing syntax warnings. I consider the code above > abundantly clear (no, I dont know what those keys mean. Since I have > no power over that, I dont consider it detrimental to clarity.) > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/