Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why PEP8 states imports should usually be on separate lines?

From PEP 8:

- Imports should usually be on separate lines, e.g.:

    Yes: import os
         import sys

    No:  import sys, os

  it's okay to say this though:

    from subprocess import Popen, PIPE

I thought comma separated style is simpler, shorter, easier to read and write, until I read PEP8. Does it have any disadvantage? PEP 8 didn't give any explaination about that.

So my question is, why is that bad?

like image 971
clowwindy Avatar asked Feb 03 '12 07:02

clowwindy


1 Answers

One reason might be that it's easier for source control systems to identify differences on a per-line basis than it is to do that within source lines.

Like a lot of PEP 8, it's a matter of preference. Consistency is more important than which option you end up choosing.

like image 190
Greg Hewgill Avatar answered Sep 28 '22 11:09

Greg Hewgill