python - Why does the ";" exist when it goes against formatting standards? -
python - Why does the ";" exist when it goes against formatting standards? -
as know, ; symbol used separate lines this:
print "hai"; print "bai"    from i've heard, goes against formatting standards python. so, if goes against formatting standards, why implemented? how used properly?
";" used in cases, have no other choice. e.g. when calling python command line , willing execute 2 statements.
$ python -c "print 'hai'; print 'bai'" hai bai    or more complex cases:
$ python -c 'a=1; b=2; print "a + b = {a} + {b} = {res}".format(a=a, b=b, res=a+b)' + b = 1 + 2 = 3    note: not take "no other choice" literally, find nice alternatives cases in comments.
 python python-2.7 
 
Comments
Post a Comment