News for hackers. Stuff that matters.
Re:What's Coming in Python 3.8 by pmart123 on Wednesday July 17, 2019 @07:54PM (#20465277)
I like "as" instead. I didn't realize that was on the table. To me, it seems more Pythonic given the typical English-like Python syntax of "with open(path) as file", "for element in items if element not in things", etc.
Re:What's Coming in Python 3.8 by mixmastamyk on Wednesday July 17, 2019 @08:10PM (#20465374)
It had some drawbacks, which a great majority of the time won't apply. I too would have preferred an "as" clause that limited to if-statements, maybe while, and comprehensions.
Re:What's Coming in Python 3.8 by Noumenon72 on Wednesday July 17, 2019 @11:04PM (#20466327)
"if m as re.match(p1, line)" is not very English-like.
Re:What's Coming in Python 3.8 by clinta on Wednesday July 17, 2019 @11:37PM (#20466474)
Because the variable goes after the as. if re.match(p1, line) as m:
Re:What's Coming in Python 3.8 by carver on Wednesday July 17, 2019 @11:23PM (#20466406)
`if re.match(p1, line) as m`, maybe?
Re:What's Coming in Python 3.8 by collinmanderson on Thursday July 18, 2019 @08:50AM (#20469199)
Yes, this is what I would expect. Much like a with statement.