3 ms·
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 f
by pmart123 7y ago
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.
- mixmastamyk 7y agoIt 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.
- Noumenon72 7y ago"if m as re.match(p1, line)" is not very English-like.
- carver 7y ago`if re.match(p1, line) as m`, maybe?
- collinmanderson 7y agoYes, this is what I would expect. Much like a with statement.
- clinta 7y agoBecause the variable goes after the as. if re.match(p1, line) as m: