且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

循环列表。

更新时间:2022-10-23 13:18:38

Jim写道:
这种类型的结构来自哪里:

mat = [''a''对于我在范围(3)]?

这将产生一个包含三个元素的列表,但是我在任何一本书中都没有看到它的参考。




它被称为列表理解。因为我不知道你的意思是什么书,所以我不能说它是否覆盖在那里。


-


Diez B. Roggisch


Jim写道:
这种类型的结构来自哪里:

mat = [''''为我的范围(3)]?

这会产生一个三个元素的列表但是
我在任何一本书中都没有看到它的参考。



它被称为列表理解它出现在Python 2.0中。

http ://www.amk.ca/python/2.0/index.h...00000000000000


Jeremy Jones


"吉姆" < JT *** @ att.net>写道:
这种类型的结构来自哪里:

mat = [''''为我的范围(3)]?br这将生成一个包含三个元素的列表,但是我没有在任何一本书中看到它的参考。




它被称为列表理解,并在Python 2.0中添加。

http://www.amk.ca/python/2.0/index.h...00000000000000
http://docs.python.org/tut/node7.htm...00000000000000
http://docs.python.org/ref/lists.html


Python 2.4引入了一种称为生成器表达式的变体:

http://www.python.org/doc/2.4/whatsnew/node4.html
http://www.python.org/peps/pep-0289.html
http://docs.python.org/ref/ genexpr.html


< / F>


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.

Jim 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.



Its called a list-comprehension. And as I don''t know what books you mean, I
can''t say if its covered there or not.

--
Regards,

Diez B. Roggisch


Jim 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 and it appeared in Python 2.0.

http://www.amk.ca/python/2.0/index.h...00000000000000

Jeremy Jones


"Jim" <jt***@att.net> 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 "list comprehension", and was added in Python 2.0.

http://www.amk.ca/python/2.0/index.h...00000000000000
http://docs.python.org/tut/node7.htm...00000000000000
http://docs.python.org/ref/lists.html

Python 2.4 introduces a variation called "generator expressions":

http://www.python.org/doc/2.4/whatsnew/node4.html
http://www.python.org/peps/pep-0289.html
http://docs.python.org/ref/genexpr.html

</F>