On Saturday, July 1, 2017 at 12:48:39 AM UTC-5, Christian Gollwitzer wrote:
> Am 30.06.17 um 04:33 schrieb Rick Johnson:
> > And to further drive home the point, you can manually
> > insert a list literal to prove this:
> >
> > >>> range(10)
> > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> > >>
On Thursday, June 29, 2017 at 9:58:23 PM UTC-5, Chris Angelico wrote:
> On Fri, Jun 30, 2017 at 12:33 PM, Rick Johnson
> > A better *FIRST* example would be something like this:
> >
> > def add(x, y):
> > return x + y
> >
> > When teaching a student about functions, the first step is
>
Am 30.06.17 um 04:33 schrieb Rick Johnson:
And to further drive home the point, you can manually insert
a list literal to prove this:
>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> for value in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
... print(value)
...
0
1
No
On Sat, Jul 1, 2017 at 1:25 PM, MRAB wrote:
> On 2017-07-01 03:12, Stefan Ram wrote:
>>
>> Terry Reedy writes:
>>>
>>> range is a class, not a function in the strict sense.
>>
>>
>>»the built-in function range() returns an iterator of integers«
>>
>> The Python Language Reference, Re
On 2017-07-01 03:12, Stefan Ram wrote:
Terry Reedy writes:
range is a class, not a function in the strict sense.
»the built-in function range() returns an iterator of integers«
The Python Language Reference, Release 3.6.0, 8.3 The for statement
Python 3.6.1 (v3.6.1:69c0db5, Mar
On 6/30/2017 1:07 PM, Irv Kalb wrote:
Thanks to everyone who responded to my question about teaching the range
function.
range is a class, not a function in the strict sense.
Classes represent concepts. Instances of classes represent instances of
the concept. Range represent the concept 'a
> On Jun 29, 2017, at 2:21 PM, Chris Angelico wrote:
>
> On Fri, Jun 30, 2017 at 6:57 AM, Irv Kalb wrote:
>> I am wondering if other teachers have run into this. Is this a real
>> problem? If so, is there any other way of explaining the concept without
>> getting into the underlying details
On Sat, Jul 1, 2017 at 2:17 AM, Stefan Ram wrote:
> However, to my defense, I must say that in this post my intend
> was to demonstrate what is happening /behind the curtains/ when
> the »for« loop is running, so in this special case, it might be
> appropriate to use a function that otherw
On Fri, 30 Jun 2017 09:17 am, Stefan Ram wrote:
b = a.__iter__()
Don't do that.
Dunder ("Double UNDERscore") methods like __iter__ should only be called by the
Python interpreter, not by the programmer. The right way to create an iterator
is to call the built-in function iter:
b = iter(a)
Hello Irv, and welcome! Good to have a teacher of Python here!
On Fri, 30 Jun 2017 06:57 am, Irv Kalb wrote:
[...]
> Now I am looking at the change in the range function. I completely understand
> the differences between, and the reasons for, how range works differently in
> Python 2 vs Python
Gregory Ewing wrote:
> Don't start with range(). Start with lists, and introduce the for
> loop as a way to iterate over lists. Leave range() until much later.
> You should be able to go a *long* way without it -- it's quite
> rare to need to iterate over a range of ints in idiomatic Python
> code
On Friday, June 30, 2017 at 8:28:23 AM UTC+5:30, Chris Angelico wrote:
> On Fri, Jun 30, 2017 at 12:33 PM, Rick Johnson wrote:
> > A better *FIRST* example would be
> > something like this:
> >
> > def add(x, y):
> > return x + y
> >
> > When teaching a student about functions, the firs
On Fri, Jun 30, 2017 at 12:33 PM, Rick Johnson
wrote:
> A better *FIRST* example would be
> something like this:
>
> def add(x, y):
> return x + y
>
> When teaching a student about functions, the first step is
> to help them understand *WHY* they need to use functions,
> and the second
On Thursday, June 29, 2017 at 4:01:07 PM UTC-5, Irv Kalb wrote:
>
> [...]
>
> But Python 3's version of the range function has been
> turned into a generator. Again, I understand why this
> happened, and I agree that this is a good change. The
> problem is, how can I explain this concept to stude
Irv Kalb wrote:
In Python 2, I easily
demonstrated the range function using a simple print statement:
print range(0, 10)
I discussed how range returns a list. I gave many examples of different
values being passed into range, and printing the resulting lists.
Next, I introduced the concept of
On 29Jun2017 13:57, Irv Kalb wrote:
Now I am looking at the change in the range function. I completely understand
the differences between, and the reasons for, how range works differently in
Python 2 vs Python 3. The problem that I've run into has to do with how to
explain what range does in
On Thu, Jun 29, 2017 at 2:57 PM, Irv Kalb wrote:
> Now I am looking at the change in the range function. I completely
> understand the differences between, and the reasons for, how range works
> differently in Python 2 vs Python 3. The problem that I've run into has to
> do with how to explai
On Fri, Jun 30, 2017 at 6:57 AM, Irv Kalb wrote:
> I am wondering if other teachers have run into this. Is this a real problem?
> If so, is there any other way of explaining the concept without getting into
> the underlying details of how a generator works? Do you think it would be
> helpful
I teach Python at two colleges in Silicon Valley. I currently teach an
introductory course on Python and most of my students have no programming
background whatsoever. Up until now, my colleges have been using Python 2.
But now, one of the colleges has made the jump to Python 3. So I am upda
19 matches
Mail list logo