Questions tagged [xrange]

xrange is a Python function that, unlike the traditional 'range' function, creates an iterator object rather than a list.

xrange is a Python function that, unlike the traditional range function, creates an iterator object rather than a list.

Their behaviors are very similar, but behind the scenes it's different.

range returns a list:

>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> range(10).__class__
<type 'list'>
>>> for i in range(10):
...     print i,
0 1 2 3 4 5 6 7 8 9

xrange returns an iterable object:

>>> xrange(10)
xrange(10)
>>> xrange(10).__class__ #It's not a list, it's a class of its own.
<type 'xrange'>
>>> for i in xrange(10): #However, it can still be iterated over.
...     print i,
0 1 2 3 4 5 6 7 8 9

While they behave basically the same, xrange works differently. range generates a list and then returns it. xrange, typically used for low-memory systems or very large ranges, generates the numbers one at a time, once on each iteration rather than all at once before the loop.

Questions that include this tag should be related to xrange, not just code that happens to include it. Here are some relevant questions:

Relevant links:

91 questions
1
vote
1 answer

Gnuplot restricting the domain of multiple data files plotted onto one plot

I am accessing data from many different files using a .plt file that I wrote. Only a specific domain of each data set is significant. I am trying to plot only the specific domain of each data set onto one graph. The data in each domain corresponds…
Daniel Schulze
  • 147
  • 2
  • 2
  • 8
1
vote
2 answers

the use of combining max, xrange and lambda function in python

I have found a code that pivotize a square matrix for LU decomposition, but I can't understand some of them. def pivotize(m): """Creates the pivoting matrix for m.""" n = len(m) ID = [[float(i == j) for i in xrange(n)] for j in…
Physicist
  • 2,848
  • 8
  • 33
  • 62
1
vote
2 answers

How to make rp and xrange dynamic?

Hey guys many thanks for taking the time to look at my problem, I have been working on this code for about 1 week (I am new to coding and to python 1 week also) Currently the loop only works if x in xrange(x) and 'rp' : 'x' is the correct number of…
AEA
  • 213
  • 2
  • 12
  • 34
1
vote
0 answers

Core plot : how to change plotSpace.xRange dynamically when device orientation change?

I've got an iOS app whith many charts. I would like to modify the xRange value when the charts is displayed in landscape mode but I can't have Core Plot doing this. I tried to totally recreate the graph by calling [graph…
Flopi
  • 73
  • 1
  • 5
0
votes
0 answers

Highchart for Android library x-range chart How to use dynamic y-axis data

While using the x-range high chart library, the x-axis contains date information data for each part, and the y-axis contains the title of each part. The y-axis contains a different number of titles per account rather than a fixed number. On the web,…
jyk
  • 21
  • 4
0
votes
1 answer

trying to use highchart xrange to display large number of categories

I'm trying to use highcharts xrange to display a large number of categories (>20). currently, I can show the data, but the categories are automatically resized so that they fit the height of the chart What the client wants is to a. configure the…
Nadav
  • 357
  • 3
  • 10
0
votes
1 answer

How to dynamically create timeline chart on click of x-range chart in highcharts angular

[enter image description here][1]I want to achieve the design given in the image below.Here I have to show task and it's related activities in different datetime. Main task is been shown as x-range chart type and when we click on the particular…
user555
  • 3
  • 5
0
votes
1 answer

bokeh categorical vbar, x_range not working

I have done basically the same plot before with different data, I don't exactly know why but this one insists in fail me once I insert the x_range into it. This code below works just fine, although I don't have all the years on the xaxis. dfnt =…
ReinholdN
  • 526
  • 5
  • 22
0
votes
1 answer

How does does xrange let you test membership?

Everyone seems to claim that xrange returns a generator but it really is its own thing: >>> xrange(10) xrange(10) >>> xrange(10).__bases__ Traceback (most recent call last): File "", line 1, in AttributeError: 'xrange' object has…
wonton
  • 7,568
  • 9
  • 56
  • 93
0
votes
1 answer

Problem with xrange in fill transparent plot

In the following Gnuplot: set xlabel "Network size, m [r]" font " Helvetica,17" set ylabel "Algorithms computation time [s]" font "Helvetica,17" $t500 << EOD 1 0 0 0 2 0.00933135 0.0640543 0.215254 3 0.00954345 0.0746418 …
user1993416
  • 698
  • 1
  • 9
  • 28
0
votes
1 answer

Highcharts xrange styling

I want to display my highchart like below. I'm using an 'xrange' type highchart for this. I'm trying to display an event for each data point where there will be a start data and an end date. So far i was able to create this chart using xrange type,…
Senal
  • 1,510
  • 1
  • 14
  • 22
0
votes
2 answers

Highcharts XRange Data and Label misalignment

I'm trying to implement a timeline widget using Highcharts xrange chartType The basic structure is YAxis Categories : Agent Name , X Axis Timeline data for Online/Offline/Break/etc I've found that the YAxis labels don't align with the actual Bar for…
Poncher
  • 53
  • 6
0
votes
1 answer

Problem with gnuplot - timestamp data mapping to xrange

what i have: csv data with timestamps in the first column, columns I want to plot selectively after that. Every data point ist roughly ten minutes apart. Data is for 24 hours. Everything else set up nicely, examples below What i want: Be able to…
lino
  • 85
  • 11
0
votes
2 answers

Is there a way to get Highstock Scrollbar to respond to trackpad?

The Highstock scrollbar only responds when you physically click and drag the bar or use the arrow keys. However ideally i'd be able to use the track pad while hovering over the scrollbar or graph itself. I've searched the Highstock/Highcharts API…
Poncher
  • 53
  • 6
0
votes
1 answer

Highcharts xrange Refusing to follow HOVER or SCROLLBAR behavior

i'm trying to massage an xrange graph into a timeline like graph and have made an overall awesome widget but i'm running into problems with the Fit and Finish. I'd like to be able to have a YAxis Scrollbar so that i can have many 'Agents' shown in…
Poncher
  • 53
  • 6