Source formatting for long expressions.

John J. Lee jjl at pobox.com
Sun Jun 9 17:33:40 EDT 2002


On 9 Jun 2002, Martin v. Loewis wrote:

> Christopher Armstrong <radix at twistedmatrix.com> writes:
>
> > Does anyone know of a tool that will beak up a very, very long
> > expression like this into multiple lines with sane indentation?
>
> Emacs indentation gives this:
>
> Ref(1, Instance('twisted.internet.app.Application',
>                 persistenceVersion=7, services={}, udpPorts=[], gid=1000,
>                 connectors=[], uid=1000, tcpPorts=[(9080,
>                                                     Instance('twisted.web.server.Site', sessions={},
[...]

Emacs python-mode will actually align only one indent level in (instead of
aligning with the opening bracket) if you have a newline after the
bracket:

Ref(1, Instance(
    'twisted.internet.app.Application',
    persistenceVersion...

The tcpPorts bit should obviously be moved to another line, though.


John




More information about the Python-list mailing list