3 ms·
I used perl almost exclusively before moving to python and it is very easy to use regular expressions. Now I use python and love how it is better at separating
by m463 7y ago
I used perl almost exclusively before moving to python and it is very easy to use regular expressions.
Now I use python and love how it is better at separating the expression from the python language (with perl you were never sure if you had escaped things correctly)
but pyython is just... clumsy
m = re.match(r'xyz',str)
if m:
do a
else:
m = re.match(r'wxy',str)
if m:
do b
else:
m = re.match(r'abc', str)
if m:
do c:
else:
...
vs:
if m := re.match(r'xyz',str):
do a
elif m := re.match(r'wxy',str)
do b
elif m := re.match(r'abc',str)
do c
...