Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32779 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2012-11-05 13:38 -0500 |
| Last post | 2012-11-05 13:38 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Difference between range and xrange ?? Terry Reedy <tjreedy@udel.edu> - 2012-11-05 13:38 -0500
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2012-11-05 13:38 -0500 |
| Subject | Re: Difference between range and xrange ?? |
| Message-ID | <mailman.3294.1352140702.27098.python-list@python.org> |
On 11/5/2012 9:23 AM, inshu chauhan wrote: > what is the difference between range and xrange.. both seem to work the > same. ? >>> range(3) [0, 1, 2] >>> xrange(3) xrange(3) You should read the appropriate manual entries before asking trivial questions. They say pretty clearly that range returns a list and xrange an xrange object. http://docs.python.org/2/library/functions.html#range http://docs.python.org/2/library/functions.html#xrange If you do not understand the entries, quote the part that confuses you and say what you are unclear about. > And which should be used where and in what situations.. ?? The entry for xrange (added after range) tries to explain this. It is for situations in which one does not want a list, but only the sequence of numbers, especially in situations where the length of the list would be large enough to make creating the unneeded list a nuisance. -- Terry Jan Reedy
Back to top | Article view | comp.lang.python
csiph-web