Source formatting for long expressions.
Martin v. Loewis
martin at v.loewis.de
Sun Jun 9 04:14:58 EDT 2002
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={},
resource=Instance('twisted.coil.web.ConfigRoot', children={},
modules=[], widgets={'config':
Instance('twisted.coil.web.AppConfiguratorPage', variables={},
dispensers=Instance('twisted.coil.coil.DispenserStorage',
dispensers={}})})))])
As you can see, it tries to align further arguments to a function
together with the opening parenthesis. I would assume that any other
auto-formatters use the same style, so you won't get any "sane"
indentation until you drop the nesting level (perhaps in favour of
method invocations).
Regards,
Martin
More information about the Python-list
mailing list