Use := operator (python 3.8+) https://www.python.org/dev/peps/pep-0572/
niedz., 26 kwi 2020 o 14:37 Николай Мостовенко <[email protected]> napisał(a): > > Hi to everybody. I was looking for any resolution for my pain in PEP and > Stack Overflow and can't find an answer. As well the similar ideas here are > 13 years old and completely missed. > I feel that I need to create a garbage code doing things like: > ``` > if myDict.get('spam'): > print(myDict.get('spam')) > ``` > or > ``` > x = myDict.get('spam') > if x is not None: > print(x) > ``` > or > ``` > days = seconds // 86400 > if days > 1: > print(days) > ``` > > and I want to use the `as` keyword instead i.e. > ``` > if myDict.get('spam') as x: print(x) > ``` > ``` > if myDict.get('spam') as x is None: print(x) > ``` > ``` > if (seconds // 86400) as days > 1: print(days) > ``` > _______________________________________________ > Python-ideas mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/T3DV7XL4ZTEYOGPI5V3ZHVJIBVNNJYBS/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- 闇に隠れた黒い力 弱い心を操る _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/ZJPMMG7CSWCMV25CHQRWZZIVGBYOFGS2/ Code of Conduct: http://python.org/psf/codeofconduct/
