writing code over several lines

Jp Calderone exarkun at intarweb.us
Tue Oct 21 11:13:59 EDT 2003


> Dnia 17 Oct 2003 06:56:48 -0700, Dominik Kaspar napisa?(a):
> > i want to initialize a constant list at the beginning of a python
> > program. but the list is too big for one line. is there any
> > possibility to spread the list over several lines, so that the code
> > looks neat again?
> >
> > something like:
> > LIST = [[100, 101, 102], [200, 201, 202], [300, 301, 302],
> >         [400, 401, 402], [500, 501, 502], [600, 601, 602],
> >         [700, 701, 702], [800, 801, 802], [900, 901, 902]]

    LIST = [range(x, x + 3) for x in range(100, 1000, 100)]

  blindly-optimizing-the-example-you-give'ly,

  Jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20031021/97fcf94f/attachment.sig>


More information about the Python-list mailing list