[Python-ideas] Re: List comprehension operators
If you didn't know, range objects already support most non-mutating list methods: >>> fakelist = range(1, 101) >>> fakelist[-1] 100 >>> fakelist[-10:] range(91, 101) >>> 50 in fakelist True >>> fakelist.index(50) 49 Range objects are more efficient than lists since they use O(1) memory instead of O(n), and many of the methods take O(1) time instead of O(n). ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VTRVLDZU35OZEMWITGZU64B6HNQZGWV4/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: List comprehension operators
On Tue, Dec 14, 2021 at 03:46:06PM -, a.kolpakov2010--- via Python-ideas wrote: > It would be awesome to be able to create a list with just: > > li = [1—100] [1-100] already has a meaning in Python: it computes 1-100 = -99 and puts it in a list. > or > > li = [1 .. 100] Is that an open, closed, or half-open interval? -- Steve ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/2ZJ2F2VRWODPPJXJRHJFSZ626TSHP37X/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: List comprehension operators
On 2021-12-14 15:46:06, a.kolpakov2010--- via Python-ideas wrote: > It would be awesome to be able to create a list with just: > > li = [1—100] > > or > > li = [1 .. 100] What's wrong with > range(1, 100) Do you really want a list only to use in a for loop? What's wrong with the iterator? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/UOCNQIA2B2P2RUB5FZV667KCIZILXAXS/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: List comprehension operators
list(range(1, 101)) I think we don't need a whole new syntax for something that's already an easy one-liner. -- Finn (Mobile) On Tue, Dec 14, 2021, 8:52 AM a.kolpakov2010--- via Python-ideas < python-ideas@python.org> wrote: > It would be awesome to be able to create a list with just: > > li = [1—100] > > or > > li = [1 .. 100] > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/CQOPU4ZMADKD5WOV5G3ZB4OAWDP4YKF6/ > Code of Conduct: http://python.org/psf/codeofconduct/ > ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EAAI7EAOXRCV2HK4QQ7QS36VUQ6B3MBR/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: List comprehension operators
Seems like a lot of work to just make list(range(1,100)) Insignificantly easier to write ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/75EWBCAPXD3PN3SQ5OZM5DOGPQYRNNXF/ Code of Conduct: http://python.org/psf/codeofconduct/