0

I am fairly good at python but I am wondering if using semi colons is looked down upon in any way. When I see code snippets online or I look at friends code etc I don't see them. If they are looked down upon, why? I don't see a problem with them. I would use them like this for example:

print("What you do want {}?".format(name));choice = input(">> ")
Throupy
  • 21
  • 6

1 Answers1

2

It's normally discouraged as it detracts from readability, from PEP8:

Compound statements (multiple statements on the same line) are generally discouraged.

Yes:

if foo == 'blah':
    do_blah_thing()
do_one()
do_two()
do_three()

Rather not:

if foo == 'blah': do_blah_thing()
do_one(); do_two(); do_three()

While sometimes it's okay to put an if/for/while with a small body on the same line, never do this for multi-clause statements. Also avoid folding such long lines!

Rather not:

if foo == 'blah': do_blah_thing()
for x in lst: total += x
while t < 10: t = delay()

Definitely not:

if foo == 'blah': do_blah_thing()
else: do_non_blah_thing()

try: something()
finally: cleanup()

do_one(); do_two(); do_three(long, argument,
                             list, like, this)

if foo == 'blah': one(); two(); three()
Chris_Rands
  • 35,097
  • 12
  • 75
  • 106