PEP 308: more use cases

Roman Suzi rnd at onego.ru
Sun Feb 9 13:17:12 EST 2003


On 9 Feb 2003, Dan Schmidt wrote:

old:
    lines = (inFile and open(inFile) or sys.stdin).readlines()
new:
    lines = (inFile if open(inFile) else sys.stdin).readlines()
supernew:
    lines = (inFile -> (open(inFile), sys.stdin)).readlines()

old:
    where, section = word[1] == 'OF' and 5 or 2, word[0][0]
new:
    where, section = (5 if word[1] == 'OF' else 2), word[0][0]
supernew:
    where, section = (word[1] == 'OF' -> (5, 2)), word[0][0]


Sincerely yours, Roman Suzi
-- 
rnd at onego.ru =\= My AI powered by Linux RedHat 7.3






More information about the Python-list mailing list