[Python-ideas] Float range class

Neil Girdhar mistersheik at gmail.com
Fri Jan 16 23:20:03 CET 2015


This looks really good.

If you want to be consistent with range, line 21 should be:

if i >= self.num or i < 0:


because i could have been less than -self.num, which is an index error.

I think you should support num == 0 and num == 1 because numpy's linspace
supports it.  Just set step to None in those cases and make sure you return
start when indexing at 0 for num == 1. I think the rest of your code will
work.

Also, you should put the code through autopep8 as there are some style
"problems" :)

Best,

Neil

On Mon, Jan 12, 2015 at 5:51 PM, 'Andrew Barnert' via python-ideas <
python-ideas at googlegroups.com> wrote:

> Sorry, hit Send accidentally.
>
> The ActiveState recipe referenced is #579000; it's the same as the class I
> posted on GitHub, but with only the NumPy implementation, rather than both
> that and Guido's version. It also links to the two earlier recipes I could
> find, and to NumPy docs and code, and the discussion section covers (I
> hope) all the caveats and bikeshedding issues that came up in this thread;
> the goal is that anyone following a link from the docs will find everything
> they might need to know about.
>
> Sent from a random iPhone
>
> On Jan 12, 2015, at 14:44, Andrew Barnert <abarnert at yahoo.com.dmarc.invalid>
> wrote:
>
> > On Jan 10, 2015, at 13:48, Ethan Furman <ethan at stoneleaf.us> wrote:
> >
> >> On 01/10/2015 11:50 AM, Guido van Rossum wrote:
> >>>
> >>> I suppose the briefest of recipes could go in the range() docs, in a
> section "what do do for floats". More extended
> >>> recipes should probably go on the activestate recipes site.
> >>
> >> The range docs do seem to be the obvious place for range recipes.
> >
> > I've created issue #23226, with a patch (the whole thing fits into one
> paragraph and a short example, so I didn't think a subsection was
> necessary, but that can easily be changed), and a link to a new ActiveState
> recipe ( that contains the same simple class that turns the NumPy algorithm
> into a lazy sequence.
> > _______________________________________________
> > Python-ideas mailing list
> > Python-ideas at python.org
> > https://mail.python.org/mailman/listinfo/python-ideas
> > Code of Conduct: http://python.org/psf/codeofconduct/
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/H69Z7qPe0Dg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150116/14414964/attachment.html>


More information about the Python-ideas mailing list