Reputation: 508
I am aware that multiple lines in python that are part of a conditional statement can be reduced into a single line.
For example:
if foo == 'bar':
do_one()
do_two()
do_three()
Can be reduced down to:
if foo == 'bar': do_one(); do_two(); do_three()
But what are the advantages of such a syntax apart from the obvious fact that it takes up fewer lines of code?
e.g. Is it more memory efficient?
Is not the standard syntax much more readable for the average Python user?
Upvotes: 1
Views: 272
Reputation: 475
AFAIK, there are no advantages of compound statements. It is actually even worse to do that as it make your code less readable. In most cases you write your code so that it is easy for humans to read it rather than to make it too complicated or short.
You can find some more infromation here
Upvotes: 1