Idioms and Anti-Idioms Question

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Mon Jun 22 10:01:07 CEST 2009


In message <H0F%l.20231$y61.5030 at news-server.bigpond.net.au>, Lie Ryan 
wrote:

> The preferred style is to put the binary operators before the line-break
> ...

Not by me. I prefer using a two-dimensional layout to make the expression 
structure more obvious:

    value = \
        (
          foo.bar()['first'][0] * baz.quux(1, 2)[5:9]
        +
          calculate_number(10, 20) * forbulate(500, 360)
        )

In this case it's not necessary, but if the factors were really long, this 
could become

    value = \
        (
                foo.bar()['first'][0]
            *
                baz.quux(1, 2)[5:9]
        +
                calculate_number(10, 20)
            *
                forbulate(500, 360)
        )





More information about the Python-list mailing list