On Tue, 08 Feb 2005 06:50:31 -0800 (PST), Jim <[EMAIL PROTECTED]> wrote:
> Where did this type of structure come from:
> 
> mat = ['a' for i in range(3)]    ?
> 
> This will produce a list of three elements but
> I don't see reference for it in any of the books.

It's called a "List Comprehension". There's a good historical reason
for the name, but you can be excused in not having looked under that
name in the index. See
<http://www.amk.ca/python/2.0/index.html#SECTION000600000000000000000>
for details.

They *should* be mentioned in most books, provided that it's vaguely
recent and covers Python 2.0 or later.

List comps have a cool new little sister, generator expressions - see
<http://www.brunningonline.net/simon/blog/archives/001025.html>.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to