Pythonic list/tuple/dict layout?
Mark Wooding
mdw at distorted.org.uk
Sun Jan 25 16:10:08 EST 2009
Akira Kitada <akitada at gmail.com> writes:
> I collected common layout from existing code and pasted them below.
> My vote would go to d1. How about yours?
It seems that I use both d1 and d4, though in both cases I omit the
trailing commas. I use d1 when each item is on a separate line, and d4
when I'm packing them onto multiple lines.
e.g.,
op = XT.make_optparse \
([('E', 'error',
{'action': 'store_const', 'dest': 'type', 'const': 'error',
'help': "Mark the window as reporting an error."}),
## ...
('t', 'title',
{'dest': 'title',
'help': "Set the window's title string."})],
version = VERSION,
usage = '%prog [-EIQWm] [-t TITLE] [-d HEADLINE] '
'MESSAGE [BUTTONS...]')
and
service_info = [('watch', T.VERSION, {
'adopted': (0, 0, '', cmd_adopted),
'kick': (1, 1, 'PEER', cmd_kick)
})]
In this latter case, were I defining multiple services, I'd indent it
differently:
service_info = [
('watch', T.VERSION, {
'adopted': (0, 0, '', cmd_adopted),
'kick': (1, 1, 'PEER', cmd_kick)
}),
##...
]
-- [mdw]
More information about the Python-list
mailing list