Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77878
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'transform': 0.07; '[1,': 0.09; 'latter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'iterable': 0.16; 'iterator': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'think.': 0.16; 'wrote:': 0.18; 'work,': 0.20; 'command': 0.22; '>>>': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'values': 0.27; 'header:X-Complaints- To:1': 0.27; "doesn't": 0.30; 'list:': 0.30; 'work.': 0.31; 'another.': 0.31; 'prints': 0.31; 'produces': 0.31; "i'd": 0.34; 'but': 0.35; 'yield': 0.36; 'should': 0.36; 'list': 0.37; 'christian': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'kind': 0.63; 'skip:n 10': 0.64; 'different': 0.65; 'between': 0.67; 'subject:Lists': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Lists |
| Date | Mon, 15 Sep 2014 09:36:46 +0200 |
| Organization | None |
| References | <12kc1a5j82lak7tmnatvhk84fh2ne08s24@4ax.com> <lv5vgi$ehv$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p57bd87df.dip0.t-ipconnect.de |
| User-Agent | KNode/4.13.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14018.1410766622.18130.python-list@python.org> (permalink) |
| Lines | 41 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1410766622 news.xs4all.nl 2969 [2001:888:2000:d::a6]:50312 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77878 |
Show key headers only | View raw
Christian Gollwitzer wrote: > Am 15.09.14 04:40, schrieb Seymore4Head: >> nums=range(1,11) >> print (nums) > >> I don't understand why the command nums=range(1,11) doesn't work. >> I would think that print(nums) should be 1,2,3 ect. >> Instead it prints range(1,11) > > It does work, but in a different way than you might think. range() does > not return a list of numbers, but rather a generator - that is an object > which produces the values one after another. But you can transform it > into a list: > > print(list(nums)) > > should give you what you want. > > Christian I'd call range() an iterable. A generator is a specific kind of iterator. The difference between iterable and iterator is that the latter cannot be restarted: >>> def f(): ... yield 1 ... yield 2 ... >>> g = f() >>> list(g) [1, 2] >>> list(g) [] # empty --> g is an iterator >>> r = range(1, 3) >>> list(r) [1, 2] >>> list(r) [1, 2] # same as before --> r is an iterable
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Lists Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-14 22:40 -0400
Re: Lists Christian Gollwitzer <auriocus@gmx.de> - 2014-09-15 08:04 +0200
Re: Lists Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-15 17:09 +1000
Re: Lists Peter Otten <__peter__@web.de> - 2014-09-15 09:36 +0200
Re: Lists Ian Kelly <ian.g.kelly@gmail.com> - 2014-09-15 09:53 -0600
Re: Lists Peter Otten <__peter__@web.de> - 2014-09-15 18:16 +0200
Re: Lists Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-15 16:59 +1000
Re: Lists Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-15 11:27 -0400
Re:Lists Dave Angel <davea@davea.name> - 2014-09-15 09:05 -0400
Re: Lists Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-15 11:28 -0400
csiph-web