[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-07 Thread Andrew Barnert via Python-ideas
On Aug 6, 2019, at 21:40, Steven D'Aprano wrote: > > Oops! Ha ha, chardet is not the only thing I had forgotten. I have my > own custom tab completer installed which completes on import lines as > well as file names inside strings. I used to have one of those, but nowadays I just rely on IPyth

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-06 Thread Steven D'Aprano
On Sat, Aug 03, 2019 at 06:56:16PM +1000, Chris Angelico wrote: > On Sat, Aug 3, 2019 at 6:16 PM Steven D'Aprano wrote: > > py> import > > Display all 492 possibilities? (y or n) > > CDROMchange_type_examplelocale site > > CFRACchardet

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-05 Thread Dominik Vilsmeier
Guido van Rossum wrote: > This is an interesting phenomenon. I'm not saying it's good or bad, I'm > just observing it (because it surprised me). Here is someone declaring that > the docs are less accessible than the code. I personally am disappointed, > given the amount of effort that we put in th

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-04 Thread Dan Sommers
On 8/4/19 1:13 PM, Anders Hovmöller wrote: >> On 3 Aug 2019, at 12:18, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: >> Once I know what SMTP is, and what the smtplib module does, and I've >> used it a couple of times, then seeing the list of names inside the >> module might remind m

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-04 Thread David Mertz
This sounds like a perfect opportunity to prove a third party module could be useful. I'm not sure how to configure tab completion callbacks in every environment like ipython, Jupyter, Python shell, PyCharm, VS Code, vim, or whatever. But without getting to that step (which is definitely possible

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-04 Thread Anders Hovmöller
> On 3 Aug 2019, at 12:18, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> > wrote: > > Once I know what SMTP is, and what the smtplib module does, > and I've used it a couple of times, then seeing the list of > names inside the module might remind me how to use it. > So maybe SMTP is an extr

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-04 Thread Dan Sommers
On 8/3/19 4:15 AM, Steven D'Aprano wrote: On Fri, Aug 02, 2019 at 02:16:52PM -0400, Dan Sommers wrote: I agree, but that's assuming that you "know" what's there and just have to be reminded. IMO, it helps less with discovering new functions, and even less than that when it comes to discovering

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-04 Thread Stephen J. Turnbull
Steven D'Aprano writes: > Which of the core devs will have the responsibility for checking that > something which is a good-quality, well-maintained, dependable package > today remains so a year from now? All of them and none of them, as usual. Also, since it's not the CPython implementatio

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-04 Thread Stephen J. Turnbull
Steven D'Aprano writes: > Do people forget that the vanilla Python REPL has come with tab > completion for nearly 20 years, and on by default for something like > seven years? > (At least on Linux/POSIX systems. I don't know if it works on Windows > or Macs.) Tab completion WFM on Mac, b

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-03 Thread Anders Hovmöller
> On 3 Aug 2019, at 11:48, Andrew Barnert via Python-ideas > wrote: > >> On Aug 3, 2019, at 01:04, Chris Angelico wrote: >> >> Not sure, but ISTR it would let you scroll through them. Not something >> you can easily do in a plain terminal. > > IPython manages to get a lot of those same Jupy

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-03 Thread Andrew Barnert via Python-ideas
On Aug 3, 2019, at 01:04, Chris Angelico wrote: > > Not sure, but ISTR it would let you scroll through them. Not something > you can easily do in a plain terminal. IPython manages to get a lot of those same Jupyter Notebook features into a plain terminal—as long as it’s either termios-friendly

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-03 Thread Chris Angelico
On Sat, Aug 3, 2019 at 6:16 PM Steven D'Aprano wrote: > > On Fri, Aug 02, 2019 at 02:16:52PM -0400, Dan Sommers wrote: > > > I agree, but that's assuming that you "know" what's there and just have > > to be reminded. IMO, it helps less with discovering new functions, and > > even less than that w

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-03 Thread Steven D'Aprano
On Fri, Aug 02, 2019 at 02:16:52PM -0400, Dan Sommers wrote: > I agree, but that's assuming that you "know" what's there and just have > to be reminded. IMO, it helps less with discovering new functions, and > even less than that when it comes to discovering "new" python modules. Pressing tab tw

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-03 Thread Chris Angelico
On Sat, Aug 3, 2019 at 5:32 PM Steven D'Aprano wrote: > > On Sat, Aug 03, 2019 at 03:56:55PM +1000, Chris Angelico wrote: > > On Sat, Aug 3, 2019 at 3:44 PM Steven D'Aprano wrote: > > > > > > On Sat, Aug 03, 2019 at 03:52:31AM +1000, Chris Angelico wrote: > > > > > > > Also a bit old-school (it t

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-03 Thread Steven D'Aprano
On Sat, Aug 03, 2019 at 03:56:55PM +1000, Chris Angelico wrote: > On Sat, Aug 3, 2019 at 3:44 PM Steven D'Aprano wrote: > > > > On Sat, Aug 03, 2019 at 03:52:31AM +1000, Chris Angelico wrote: > > > > > Also a bit old-school (it took me many years to learn the value of > > > syntax highlighting), a

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Steven D'Aprano
On Fri, Aug 02, 2019 at 11:34:31AM -0700, Christopher Barker wrote: > As for "consume" -- I think it very much meets the requirement of > non-trivial and generally useful. Seems pretty trivial to me: for x in iterable: pass ABout a year ago, there was a thread about introducing a keyword, "do",

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Brendan Barnwell
On 2019-08-02 22:37, Steven D'Aprano wrote: On Sat, Aug 03, 2019 at 03:52:31AM +1000, Chris Angelico wrote: Also a bit old-school (it took me many years to learn the value of syntax highlighting), and an educator, and I've seen students start out with Jupyter. As an alternative to the vanilla R

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Chris Angelico
On Sat, Aug 3, 2019 at 3:44 PM Steven D'Aprano wrote: > > On Sat, Aug 03, 2019 at 03:52:31AM +1000, Chris Angelico wrote: > > > Also a bit old-school (it took me many years to learn the value of > > syntax highlighting), and an educator, and I've seen students start > > out with Jupyter. As an alt

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Steven D'Aprano
On Sat, Aug 03, 2019 at 03:52:31AM +1000, Chris Angelico wrote: > Also a bit old-school (it took me many years to learn the value of > syntax highlighting), and an educator, and I've seen students start > out with Jupyter. As an alternative to the vanilla REPL, I think it's > awesome [...] > But

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Steven D'Aprano
On Sat, Aug 03, 2019 at 10:02:39AM +1000, Chris Angelico wrote: > On Sat, Aug 3, 2019 at 9:48 AM Steven D'Aprano wrote: > > > > On Fri, Aug 02, 2019 at 07:52:37AM +1000, Chris Angelico wrote: > > > > > Maybe there needs to be a > > > second-tier recommendation, where a list of packages can be give

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
On Aug 2, 2019, at 19:22, Brendan Barnwell wrote: > >> On 2019-08-02 19:16, Andrew Barnert wrote: >> >> So, that’s the way forward. You could port the recipes to C and >> change the docs recipes to be “roughly equivalent” Python code in the >> help for each function. Or you could port itertools

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
On Aug 2, 2019, at 11:34, Christopher Barker wrote: > > The other issue here, in the context of the OP's proposal, is that it's less > than obvious that that's what a user would want when they want to operate on > all the items in a iterable without creating a new iterable. To Guido's > point,

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Brendan Barnwell
On 2019-08-02 19:16, Andrew Barnert wrote: PEP 399 says all _new_ modules (that don’t have a good reason for a special dispensation) have to have a pure Python implementation. But it explicitly says that pre-existing modules in the stdlib didn’t need to be rewritten, and most of them haven’t been

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
On Aug 2, 2019, at 15:45, Steven D'Aprano wrote: > > Are infinite for-loops that common that people get excited by cycle? > That sounds like the "here's a hammer, now every problem is a nail" > issue. "itertools.cycle is cool, I must use it as often as possible!" Well, they’re probably excited

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
On Aug 2, 2019, at 11:55, Brendan Barnwell wrote: > >> On 2019-08-02 10:11, Andrew Barnert wrote: >> Honestly, I think a lot of the resistance is the implementation >> issue, or at least it’s the reason the resistance is hard to >> overcome. If someone isn’t sure whether the benefit of having >>

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Chris Angelico
On Sat, Aug 3, 2019 at 9:48 AM Steven D'Aprano wrote: > > On Fri, Aug 02, 2019 at 07:52:37AM +1000, Chris Angelico wrote: > > > Maybe there needs to be a > > second-tier recommendation, where a list of packages can be given that > > aren't category killers, but have been given the blessing of the

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Steven D'Aprano
On Fri, Aug 02, 2019 at 07:52:37AM +1000, Chris Angelico wrote: > Maybe there needs to be a > second-tier recommendation, where a list of packages can be given that > aren't category killers, but have been given the blessing of the > Python devs as "this is a good-quality, well-maintained package,

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Steven D'Aprano
On Thu, Aug 01, 2019 at 12:31:48PM -0700, Andrew Barnert via Python-ideas wrote: > Plus, there is another potential argument for adding at least some of > the recipes to the module. When I show a novice how to import and use > cycle, they they get excited and go off and use it. Are infinite for

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread David Mertz
There *is* also the '%load' magic. But 'from my_stuff import *' is almost always a better idea. On Fri, Aug 2, 2019, 2:49 PM Christopher Barker wrote: > Getting really OT now, but quickly: > > On Fri, Aug 2, 2019 at 11:28 AM Chris Angelico wrote: > >> On Sat, Aug 3, 2019 at 4:19 AM Ricky Teache

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Barry Scott
> On 1 Aug 2019, at 19:11, Guido van Rossum > wrote: > > This is an interesting phenomenon. I'm not saying it's good or bad, I'm just > observing it (because it surprised me). Here is someone declaring that the > docs are less accessible than the code. I personally am

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Brendan Barnwell
On 2019-08-02 10:11, Andrew Barnert wrote: Honestly, I think a lot of the resistance is the implementation issue, or at least it’s the reason the resistance is hard to overcome. If someone isn’t sure whether the benefit of having itertools.consume is worth the cost of implementing and maintaining

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Ricky Teachey
> > > I think he means putting: > > > > import my_python_file > > > > in a cell, like any other python code. > Yes, that is all I meant. My super powered text editor experience is limited to Notepad++. Perhaps I have a lot to learn about what makes a good text editor for code. And I'm always will

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Chris Angelico
On Sat, Aug 3, 2019 at 4:39 AM Christopher Barker wrote: > > Getting really OT now, but quickly: Off-list because it really is. > On Fri, Aug 2, 2019 at 11:28 AM Chris Angelico wrote: >> >> On Sat, Aug 3, 2019 at 4:19 AM Ricky Teachey wrote: >> > Remember that Jupyter has a pretty nice text ed

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Christopher Barker
Getting really OT now, but quickly: On Fri, Aug 2, 2019 at 11:28 AM Chris Angelico wrote: > On Sat, Aug 3, 2019 at 4:19 AM Ricky Teachey wrote: > > Remember that Jupyter has a pretty nice text editor Actually, I think it's pretty darn crappy -- at least compared to any "proper" coding editor.

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Christopher Barker
This has gotten a bit OT, but I’ll roll with it. But what about `pip install more-itertools`? Hopefully you become >> comfortable with that a lot faster than 3 years in. > > more-itertools Is kind of a special case (or at least different case), as it’s a collection of handy general purpose ut

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Brendan Barnwell
On 2019-08-02 06:37, Rhodri James wrote: On 02/08/2019 06:26, Brendan Barnwell wrote: It is massively more discoverable, for one simple reason: autocomplete. In teaching people to program, I often use Jupyter notebook, which has great autocomplete functionality that can also bring up

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Christopher Barker
On Fri, Aug 2, 2019 at 10:54 AM Chris Angelico wrote: > Also a bit old-school (it took me many years to learn the value of > syntax highlighting), and an educator, and I've seen students start > out with Jupyter. As an alternative to the vanilla REPL, I think it's > awesome if a little expensive

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Dan Sommers
On 8/2/19 1:18 PM, David Mertz wrote: > I'm definitely on the old side of the distribution of programmers ... Throw me into that bucket, too. I use autocomplete to save typing rather than to discover new functionality. Autocompletion is great, if you know where to start. In the case that star

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Chris Angelico
On Sat, Aug 3, 2019 at 4:19 AM Ricky Teachey wrote: >> >> as an >> alternative to a text editor, it's an attractive nuisance. Yes, you >> can try things out and see the results instantly, AND you can save it, >> edit, rerun, etc; the cost is that debugging becomes a nightmare. > > > Remember that

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Ricky Teachey
> > as an > alternative to a text editor, it's an attractive nuisance. Yes, you > can try things out and see the results instantly, AND you can save it, > edit, rerun, etc; the cost is that debugging becomes a nightmare. > Remember that Jupyter has a pretty nice text editor (with syntax highlighti

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Chris Angelico
On Sat, Aug 3, 2019 at 12:48 AM Ricky Teachey wrote: > > Notebooks in particular-- more than IDEs, I think-- are changing the way > people learn. if I were teaching someone new today, I'd have them use Jupyter > right away, probably not the repl. > > But I still use the docs a lot too. Also a b

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread David Mertz
I'm definitely on the old side of the distribution of programmers, and I strongly appreciate tab expansion in tools like Jupyter and vim. I never used a full "IDE", whatever the boundary line is. But exactly that kind of reminder of e.g. "what's in itertools again?" is very helpful to me, both when

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
On Aug 1, 2019, at 22:26, Brendan Barnwell wrote: > >> On 2019-08-01 12:31, Andrew Barnert via Python-ideas wrote: >>> On Aug 1, 2019, at 10:48, Eli Berkowitz wrote: >>> > >>> >In terms of an argument for why it should be included, for most Python >>> >users the itertools recipes remain unseen.

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Rhodri James
On 02/08/2019 15:22, Guido van Rossum wrote: There seems to be a clash of generations here, or perhaps a clash of different educational paths. Very likely. I did my computer science learning on an IBM mainframe, with a local front-end over MVS. A full-screen editor was introduced during the

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Stefan Krah
On Fri, Aug 02, 2019 at 10:48:26AM -0400, Ricky Teachey wrote: > I agree it is more a clash of learning paths/training. I started out-- with > ZERO knowledge-- in 2014 just before Jupyter started to be popular, and the > more I have used it (as well as VSCode and Pycharm), the more I have found > m

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Ricky Teachey
> > > It is massively more discoverable, for one simple reason: >> > autocomplete. >> >> I am very uncomfortable with >> IDEs that try to do my thinking for me, and I start turning things off >> on those occasions when I am forced to use them. It would even occur to >> me to try autocompletio

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Guido van Rossum
On Fri, Aug 2, 2019 at 6:38 AM Rhodri James wrote: > On 02/08/2019 06:26, Brendan Barnwell wrote: > > It is massively more discoverable, for one simple reason: > > autocomplete. > > > > In teaching people to program, I often use Jupyter notebook, which > > has great autocomplete functio

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Rhodri James
On 02/08/2019 06:26, Brendan Barnwell wrote: It is massively more discoverable, for one simple reason: autocomplete. In teaching people to program, I often use Jupyter notebook, which has great autocomplete functionality that can also bring up the documentation on any function.  You

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Brendan Barnwell
On 2019-08-01 12:31, Andrew Barnert via Python-ideas wrote: On Aug 1, 2019, at 10:48, Eli Berkowitz wrote: > >In terms of an argument for why it should be included, for most Python users the itertools recipes remain unseen. Sure. But do you also know all of the functions in the module? Would

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Stephen J. Turnbull
Andrew Barnert via Python-ideas writes: > > Maybe there needs to be a second-tier recommendation, where a > > list of packages can be given that aren't category killers, but > > have been given the blessing of the Python devs as "this is a > > good-quality, well-maintained package, and can be

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Stephen J. Turnbull
Rob Cliffe via Python-ideas writes: > > > On 01/08/2019 19:11:18, Guido van Rossum wrote: > > Here is someone declaring that the docs are less accessible than the > > code. I personally am disappointed, given the amount of effort that we > > put in those docs. But maybe this is true. If w

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
On Aug 1, 2019, at 14:52, Chris Angelico wrote: > > The stdlib does reference a small number of third-party packages > (requests etc). We don't want to go overboard with that, but I think > more-itertools is worth referencing. Maybe there needs to be a > second-tier recommendation, where a list o

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Chris Angelico
On Fri, Aug 2, 2019 at 7:36 AM Ricky Teachey wrote: >> >> But what about `pip install more-itertools`? Hopefully you become >> comfortable with that a lot faster than 3 years in. If not, the packaging >> team will probably be disappointed to hear it… >> >> (I have occasionally had other people i

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Ricky Teachey
> > But what about `pip install more-itertools`? Hopefully you become > comfortable with that a lot faster than 3 years in. If not, the packaging > team will probably be disappointed to hear it… > > (I have occasionally had other people insist that I shouldn’t tell users > to pip install things… )

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Guido van Rossum
On Thu, Aug 1, 2019 at 12:54 PM Ricky Teachey wrote: > When I show a novice how to import and use cycle, they they get excited >> and go off and use it. When I show them how to copy and paste grouper, they >> sometimes seem reluctant— >> > > TLDR: a beginner can read, understand, and use the iter

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
On Aug 1, 2019, at 12:52, Ricky Teachey wrote: > > TLDR: a beginner can read, understand, and use the itertools module > incredibly easily. But putting a recipe aside for your own use later? Forget > it. That took my almost 3 years to get comfortable with. I can understand that. I could tell y

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Rob Cliffe via Python-ideas
On 01/08/2019 19:11:18, Guido van Rossum wrote: Here is someone declaring that the docs are less accessible than the code. I personally am disappointed, given the amount of effort that we put in those docs. But maybe this is true. If we can't get people to peruse the docs, should we bother?

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Ricky Teachey
> > When I show a novice how to import and use cycle, they they get excited > and go off and use it. When I show them how to copy and paste grouper, they > sometimes seem reluctant— > TLDR: a beginner can read, understand, and use the itertools module incredibly easily. But putting a recipe aside

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
On Aug 1, 2019, at 10:48, Eli Berkowitz wrote: > > In terms of an argument for why it should be included, for most Python users > the itertools recipes remain unseen. Sure. But do you also know all of the functions in the module? Would you notice or a new one got added? In practical terms, how

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Tim Peters
[Guido] > ,,, > I learned something in this thread -- I had no idea that the deque datatype > even has an option to limit its size (and silently drop older values as new > ones are added), let alone that the case of setting the size to zero is > optimized in the C code. But more importantly, I don'

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
On Aug 1, 2019, at 09:27, Christopher Barker wrote: > > > >> On Thu, Aug 1, 2019 at 9:19 AM Andrew Barnert via Python-ideas >> wrote: > >> > Given that in 3.x every stdlib module is supposed to be in Python with an >> > optional C accelerator, > > Is this written down somewhere? And when w

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Guido van Rossum
On Thu, Aug 1, 2019 at 10:49 AM Eli Berkowitz wrote: > In terms of an argument for why it should be included, for most Python > users the itertools recipes remain unseen. I consider myself relatively > fluent in Python (not compared to y'all of course) and hadn't seen them > until I started this

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Brett Cannon
On Thu, Aug 1, 2019 at 10:49 AM Eli Berkowitz wrote: > In terms of an argument for why it should be included, for most Python > users the itertools recipes remain unseen. I consider myself relatively > fluent in Python (not compared to y'all of course) and hadn't seen them > until I started this

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Eli Berkowitz
In terms of an argument for why it should be included, for most Python users the itertools recipes remain unseen. I consider myself relatively fluent in Python (not compared to y'all of course) and hadn't seen them until I started this thread. If I had to hazard a guess, they're probably unused

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Christopher Barker
On Thu, Aug 1, 2019 at 9:19 AM Andrew Barnert via Python-ideas < python-ideas@python.org> wrote: > > Given that in 3.x every stdlib module is supposed to be in Python with an > optional C accelerator, > Is this written down somewhere? And when was that policy decided? When we added math.is_close

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
> On Aug 1, 2019, at 00:06, Eli Berkowitz wrote: > > These are all fair and good points :) > > I really like the idea of writing a function that exhausts an iterator and > using that. It seems like this should be a part of the itertools package at > least, maybe called `run`, `do`, or `exhaust

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Eli Berkowitz
These are all fair and good points :) I really like the idea of writing a function that exhausts an iterator and using that. It seems like this should be a part of the itertools package at least, maybe called `run`, `do`, or `exhaust`. ``` from itertools import run run(list2.append(item * 6) fo

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Andrew Barnert via Python-ideas
On Jul 26, 2019, at 15:05, Kyle Stanley wrote: > > Andrew Barnert wrote: >> consume(print(item) for item in lst) > > From my understanding, consume() effectively provides the functionality the > author was looking for. Exactly. And it’s readable and concise, and there’s even an implementation i

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Josh Rosenberg
On Fri, Jul 26, 2019 at 10:06 PM Kyle Stanley wrote: > From my understanding, consume() effectively provides the functionality the > author was looking for. Also, between the options of `for _ in iter:` vs > `colllections.deque(it, maxlen=0)`, how significant is the performance > difference? > >

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Steven D'Aprano
On Fri, Jul 26, 2019 at 12:51:46PM -, Eli Berkowitz wrote: > (This is my first time posting on any Python list; I've tried to search for > this idea and didn't find it but if I looked in the wrong places/this has > already been discussed I apologize and feel free to tell me!) > > Say you ha

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Eric V. Smith
On 7/26/2019 6:05 PM, Kyle Stanley wrote: Andrew Barnert wrote: consume(print(item) for item in lst) From my understanding, consume() effectively provides the functionality the author was looking for. Also, between the options of `for _ in iter:` vs `colllections.deque(it, maxlen=0)`, how sig

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Kyle Stanley
Andrew Barnert wrote: > consume(print(item) for item in lst) >From my understanding, consume() effectively provides the functionality the author was looking for. Also, between the options of `for _ in iter:` vs `colllections.deque(it, maxlen=0)`, how significant is the performance difference? I

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Andrew Barnert via Python-ideas
On Jul 26, 2019, at 05:51, Eli Berkowitz wrote: > > #1 > for item in lst: >print(item) > > # 2 > [print(item) for item in lst] > > # 3 > for item in lst: print(item) > ``` Normally, expressions are about producing a value, and if you only care about side effects, you want a statement. Th

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Brett Cannon
On Fri, Jul 26, 2019 at 6:57 AM Eli Berkowitz wrote: > By #1 "should" be a 1-liner, I mean that I think a reasonable goal is to > have a good syntax for this operation to be one line. > > And for #3 I'm basing it also off Pep 8: "Compound statements (multiple > statements on the same line) are ge

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Eli Berkowitz
By #1 "should" be a 1-liner, I mean that I think a reasonable goal is to have a good syntax for this operation to be one line. And for #3 I'm basing it also off Pep 8: "Compound statements (multiple statements on the same line) are generally discouraged." Given that the proposed alternative isn

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Paul Moore
On Fri, 26 Jul 2019 at 13:55, Eli Berkowitz wrote: > Say you have a list and you want to perform some operation on each item in > the list - but you don't need to store the result in a list. > > There are three simple ways of doing this, at least as far as I know: > ([print(item)] could be any e