[Python-ideas] Float range class
Ethan Furman
ethan at stoneleaf.us
Thu Jan 8 20:17:50 CET 2015
On 01/08/2015 10:40 AM, Nathaniel Smith wrote:
> class FRange:
> def __init__(start, stop, step):
> self.start = start
> self.stop = stop
> self.step = step
>
> def __getitem__(self, i):
> x = self.start + i * self.step
> if x > self.stop:
> raise IndexError
return x # ;)
>
> def __iter__(self):
> i = 0
> while True:
> try:
> yield self[i]
> except IndexError:
> return
> i += 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150108/2e601a15/attachment.sig>
More information about the Python-ideas
mailing list