__iter__
.import decimal
class drange():
def __init__(self, start, stop, step = 1):
self.start = decimal.Decimal(start)
self.stop = decimal.Decimal(stop)
self.step = decimal.Decimal(step)
self.value = self.start
def __iter__(self):
self.value = self.start # <-- Вот тут самое главное
return self
def __next__(self):
if self.step > 0 and self.value < self.stop or self.step < 0 and self.value > self.stop:
current = self.value
self.value += self.step
return current
else:
raise StopIteration()
def __len__(self):
return max(0, int((self.stop - self.start) / self.step + 1))
# Пользуемся
weights = drange(126, 127 + 0.5, '0.5')
heights = drange(150, 153 + 1, 1)
for weight in weights:
for height in heights:
print(height, '-', weight)
150 - 126
151 - 126
152 - 126
153 - 126
150 - 126.5
151 - 126.5
152 - 126.5
153 - 126.5
150 - 127.0
151 - 127.0
152 - 127.0
153 - 127.0
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
jQuery(document).ready(function() {
var params = getUrlVars();
$('select option[value="' + params['style'] + '"]').attr('selected', 'selected');
});
<div class="flexslider">
<ul class="slides">
<li data-duration="100">
<img src="https://upload.wikimedia.org/wikipedia/commons/c/ce/Burger_King_Restaurant_in_Sherman_Oaks%2C_California_-_panoramio.jpg" />
</li>
<li data-duration="500">
<img src="https://upload.wikimedia.org/wikipedia/commons/a/ae/Canoga_Park%2C_California_-_panoramio.jpg" />
</li>
<li data-duration="5000">
<img src="https://upload.wikimedia.org/wikipedia/commons/c/cd/CHS_Building.JPG" />
</li>
<li data-duration="1000">
<img src="https://upload.wikimedia.org/wikipedia/commons/e/e4/First_Street_Bridge._Downtown_Los_Angeles%2C_CA._Looking_West._-_panoramio.jpg" />
</li>
</ul>
</div>
$(document).ready(function() {
var slider = $('.flexslider').flexslider({
slideshowSpeed: 6000,
directionNav: true,
slideshow: 1,
animation: 'fade',
animationLoop: true,
after: function(slider) {
slider.stop();
slider.vars.slideshowSpeed = $(slider.slides[slider.currentSlide]).data('duration');
slider.play();
}
});
});