Allowing comments after the line continuation backslash
Lawrence D'Oliveiro
ldo at geek-central.gen.new_zealand
Mon Nov 8 18:29:13 EST 2010
In message <87fwvdb69k.fsf.mdw at metalzone.distorted.org.uk>, Mark Wooding
wrote:
> Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> writes:
>
>> for \
>> Description, Attr, ColorList \
>> in \
>> (
>> ("normal", "image", MainWindow.ColorsNormalList),
>> ("highlighted", "highlight",MainWindow.ColorsHighlightedList),
>> ("selected", "select", MainWindow.ColorsSelectedList),
>> ) \
>> :
>> ...
>> #end for
>>
>> Does this make more sense now?
>
> Ugh, no!
>
> for descr, attr, colours in [
> ('normal', 'image', 'Normal'),
> ('highlighted', 'highlight', 'Highlighted'),
> ('selected', 'select', 'Selected')]:
> colourlist = getattr(MainWindow, 'Colors%sList' % colours)
> ## ...
But then you lose the ability to match up the bracketing symbols. That’s why
I put them on lines by themselves.
> To be honest, there's so much regularity in that table that I'd consider
> generating it from a shorter list. This would obviously involve
> refactoring something else to eliminate the image/normal asymmetry. I'd
> also consider making the ColorsMumbleList attribute collection into a
> dictionary.
Maybe you should look at the code in context
<https://github.com/ldo/dvd_menu_animator>, then you can express some more
opinions on how to improve it.
More information about the Python-list
mailing list