turn text lines into a list

Matthias Huening mhuening at zedat.fu-berlin.de
Mon Jun 27 06:54:37 EDT 2005


Xah Lee (27.06.2005 12:33):
> i have a large number of lines i want to turn into a list.
> In perl, i can do
> 
> @corenames=qw(
> rb_basic_islamic
> sq1_pentagonTile
> sq_arc501Tile
> sq_arc503Tile
> );
> 
> use Data::Dumper;
> print Dumper(\@corenames);
> 
> ----------
> is there some shortcut to turn lines into list in Python?

txt = """rb_basic_islamic
sq1_pentagonTile
sq_arc501Tile
sq_arc503Tile"""

print txt.splitlines()

Matthias



More information about the Python-list mailing list