Re: Re: Generators, generator expressions, and loops

2018-11-16 Thread Peter via Python-list
Lovely, succinct answers. On 17/11/2018 2:44 AM, Ian Kelly wrote: On Fri, Nov 16, 2018 at 7:57 AM Steve Keller wrote: I have looked at generators, generator expressions, and iterators and I try to get more familiar with these. 1. How would I loop over all (with no upper bound) integers or al

Re: Python Interpreters In Eclipse

2018-11-16 Thread Liste guru
Il 16/11/2018 21:08, Jaxson Baerg ha scritto: Hey, I'm attempting to use python in eclipse and am having trouble with the python interpreter. I am using Eclipse 2018-09 and the latest PyDev and Python 3.7.1. When declaring python-3.7.1.exe as an interpreter it gives an error saying it was unable

Python Interpreters In Eclipse

2018-11-16 Thread Jaxson Baerg
Hey, I'm attempting to use python in eclipse and am having trouble with the python interpreter. I am using Eclipse 2018-09 and the latest PyDev and Python 3.7.1. When declaring python-3.7.1.exe as an interpreter it gives an error saying it was unable to get info on the interpreter. It also says a p

Re: IDLE Default Working Directory

2018-11-16 Thread Irv Kalb
> On Nov 15, 2018, at 2:44 PM, eryk sun wrote: > > On 11/14/18, Irv Kalb wrote: >> >> When working with data files, I tell students to put their project (their >> main program and any other related files) in a folder. Then, in their calls >> to "open", I tell them to just give the name of th

Re: Generators, generator expressions, and loops

2018-11-16 Thread Matt Wheeler
> On 16 Nov 2018, at 14:54, Steve Keller wrote: > More elegant are generator expressions but I cannot think of a way > without giving an upper limit: > >for i in (2 ** i for i in range(100)): >... > > which looks ugly. Also, the double for-loop (and also the two loops > in the

Re: Generators, generator expressions, and loops

2018-11-16 Thread Santiago Basulto
Try itertools.count() . On Fri, Nov 16, 2018 at 12:08 PM Steve Keller wrote: > Cancel ill-formated article > -- > https://mail.python.org/mailman/listinfo/python-list > -- Santiago Basulto.- Co-founder @ rmotr.com -- https://m

Re: Why do integers compare equal to booleans?

2018-11-16 Thread Santiago Basulto
> Because Python used not to have a boolean type and used the integers 0 and 1 instead Exactly as Jon says. I wrote a post some time ago with more info about it: https://blog.rmotr.com/those-tricky-python-booleans-2100d5df92c On Fri, Nov 16, 2018 at 12:23 PM duncan smith wrote: > On 16/11/18 14

Re: Generators, generator expressions, and loops

2018-11-16 Thread Ian Kelly
On Fri, Nov 16, 2018 at 7:57 AM Steve Keller wrote: > > I have looked at generators, generator expressions, and iterators and > I try to get more familiar with these. > > 1. How would I loop over all (with no upper bound) integers or all > powers of two, for example? > > In C it would be > >fo

Re: Iterators of iterators

2018-11-16 Thread Ian Kelly
On Fri, Nov 16, 2018 at 8:01 AM Steve Keller wrote: > > I wonder why iterators do have an __iter__() method? I thought > iterable objects would have an __iter__() method (but no __next__()) > to create an iterator for it, and that would have the __next__() > method but no __iter__(). > > $ py

RE: Why do integers compare equal to booleans?

2018-11-16 Thread David Raymond
A boolean type didn't come about until version 2.3, and even now they still inherit from integers. Some links for you: https://docs.python.org/3.7/whatsnew/2.3.html#pep-285-a-boolean-type https://docs.python.org/3.7/library/stdtypes.html#boolean-values https://docs.python.org/3.7/reference/datam

Re: Why do integers compare equal to booleans?

2018-11-16 Thread duncan smith
On 16/11/18 14:51, Steve Keller wrote: > Why do the integers 0 and 1 compare equal to the boolean values False > and True and all other integers to neither of them? > > $ python3 > Python 3.5.2 (default, Nov 12 2018, 13:43:14) > [GCC 5.4.0 20160609] on linux > Type "help", "copyrig

Re: Why do integers compare equal to booleans?

2018-11-16 Thread Jon Ribbens
On 2018-11-16, Steve Keller wrote: > Why do the integers 0 and 1 compare equal to the boolean values False > and True and all other integers to neither of them? Because Python used not to have a boolean type and used the integers 0 and 1 instead, so when the boolean type was introduced True and F

Generators, generator expressions, and loops

2018-11-16 Thread Steve Keller
Cancel ill-formated article -- https://mail.python.org/mailman/listinfo/python-list

Iterators of iterators

2018-11-16 Thread Steve Keller
I wonder why iterators do have an __iter__() method? I thought iterable objects would have an __iter__() method (but no __next__()) to create an iterator for it, and that would have the __next__() method but no __iter__(). $ python3 Python 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5

Generators, generator expressions, and loops

2018-11-16 Thread Steve Keller
I have looked at generators, generator expressions, and iterators and I try to get more familiar with these. 1. How would I loop over all (with no upper bound) integers or all powers of two, for example? In C it would be for (int i = 0; ; i++) { ... } or for (int i = 1; ; i *= 2) { ... } I

Generators, generator expressions, and loops

2018-11-16 Thread Steve Keller
I have looked at generators, generator expressions, and iterators and I try to get more familiar with these. 1. How would I loop over all (with no upper bound) integers or all powers of two, for example? In C it would be for (int i = 0; ; i++) { ... } or for (int i = 1; ; i *= 2) { ... } I

Why do integers compare equal to booleans?

2018-11-16 Thread Steve Keller
Why do the integers 0 and 1 compare equal to the boolean values False and True and all other integers to neither of them? $ python3 Python 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.