Re: A desperate lunge for on-topic-ness

Discussion in 'Python' started by Jean-Michel Pichavant, Oct 18, 2012.

  1. ----- Original Message -----
    > On 2012-10-18, Zero Piraeus <> wrote:
    >
    > > What are people's preferred strategies for dealing with lines that
    > > go
    > > over 79 characters? A few I can think of off the bat:

    >
    > I try to do what's easiest to read and understand. Sometimes that
    > means using a line thats 120 characters long, sometimes that means
    > breaking up the line.
    >


    Imo, def. a good approach to the problem. Mark's also pointed the fact that the guidelines themselves state that rules are made to be broken when they need to be.
    The 79 char limit purpose is to allow someone to read the code on a 80 char terminal (and allow old printers to print the code). If following this rules breaks readability for all other terminals, meaning 99,99% of them, you know what to do.

    JM
     
    Jean-Michel Pichavant, Oct 18, 2012
    #1
    1. Advertising

  2. On Thu, 18 Oct 2012 15:59:18 +0200, Jean-Michel Pichavant wrote:

    > ----- Original Message -----
    >> On 2012-10-18, Zero Piraeus <> wrote:
    >>
    >> > What are people's preferred strategies for dealing with lines that go
    >> > over 79 characters? A few I can think of off the bat:

    >>
    >> I try to do what's easiest to read and understand. Sometimes that
    >> means using a line thats 120 characters long, sometimes that means
    >> breaking up the line.
    >>
    >>

    > Imo, def. a good approach to the problem. Mark's also pointed the fact
    > that the guidelines themselves state that rules are made to be broken
    > when they need to be. The 79 char limit purpose is to allow someone to
    > read the code on a 80 char terminal (and allow old printers to print the
    > code).


    And people who like to have multiple windows open side-by-side.

    And people who may have some need to email or post code inline rather
    than as attached files (say, on this list).

    And people who may need to run external tools over their code (e.g. grep,
    diff) and view the output in a terminal with, say, 120 character width.
    This allows ~80 characters for the source and ~40 characters for whatever
    extraneous information the tool displays on the same line.

    And, quite frankly, people who care more about the readability of their
    code than about squeezing in as much processing into a single line of
    text as possible.

    In my not-in-the-slightest-bit-humble opinion, if someone is consistently
    needing more than 79 characters per line, they're probably doing one or
    more of the following coding sins:

    - using one-liners for the sake of one liners;
    - code that is too deeply nested (if you need more than 3 or 4 indents
    for a block, you're probably doing something wrong);
    - doing too much in one line, e.g. overly busy list comps;
    - excessively long variable or function names;
    - badly designed functions or classes that take too many arguments;
    - misuse of Hungarian Notation; and
    - violations of the Law of Demeter.

    Or possibly they're just unlucky to require a library with excessively
    long names and can't do much about it.

    I'm not saying that every line that exceeds 79 characters is crap, but I
    am saying that if you have trouble keeping *at least* 90% of your code
    under 79 characters, you may very well be suffering from poor design,
    lousy code, or both.

    Flame away :)



    --
    Steven
     
    Steven D'Aprano, Oct 19, 2012
    #2
    1. Advertising

  3. On 2012-10-18, at 6:34 PM, Steven D'Aprano <> wrote:

    > Flame away :)



    This post made my Friday, even though I'm sitting on a nearly two hour bus ride into work because I missed my commuter train. Just wanted you to know ;) You noted *every* reason (and them some) why my own code never passed 79 chars and why I try to instil that same value in others.
     
    Demian Brecht, Oct 19, 2012
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zero Piraeus

    A desperate lunge for on-topic-ness

    Zero Piraeus, Oct 18, 2012, in forum: Python
    Replies:
    24
    Views:
    372
    Krzysztof Voss
    Oct 19, 2012
  2. Chris Angelico

    Re: A desperate lunge for on-topic-ness

    Chris Angelico, Oct 18, 2012, in forum: Python
    Replies:
    0
    Views:
    151
    Chris Angelico
    Oct 18, 2012
  3. Demian Brecht

    Re: A desperate lunge for on-topic-ness

    Demian Brecht, Oct 18, 2012, in forum: Python
    Replies:
    0
    Views:
    199
    Demian Brecht
    Oct 18, 2012
  4. Mark Lawrence

    Re: A desperate lunge for on-topic-ness

    Mark Lawrence, Oct 18, 2012, in forum: Python
    Replies:
    0
    Views:
    147
    Mark Lawrence
    Oct 18, 2012
  5. Chris Angelico

    Re: A desperate lunge for on-topic-ness

    Chris Angelico, Oct 18, 2012, in forum: Python
    Replies:
    0
    Views:
    164
    Chris Angelico
    Oct 18, 2012
Loading...

Share This Page