[Edu-sig] source code from SA:10648

kirby urner kirby.urner at gmail.com
Fri Jul 16 15:59:59 CEST 2010


Good question John.

My lengthy post was confusing because I want on the riff about
how range() doesn't return a list in 3.x (but a range object,
iterable but not an iterator).

In point of fact, I'm using Python 2.6 from start to finish in
this class, with only allusions and honorable mentions of 3.x
features.  Using print as a function is optional in 2.6 without
importing anything special.

Here we are:

>>> import sys
>>> sys.version
'2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]'
>>> "{0}".format(1)
'1'
>>> print(1)
1

I'm actually forgetting what we might need to import anymore, to
make 2.6 behave like 3.x, when it comes to print and string formatting.


Kirby


On Fri, Jul 16, 2010 at 6:17 AM, John Posner <jjposner at optimum.net> wrote:
> Kirby wrote:
>
>>     for question, answer in quiz:
>>         print(question)
>>         user_answer = raw_input("Your answer? ")
>>
>
> Kirby, will the class be using Py2 or Py3? It looks like you're
> mix-and-matching, using the *print* function (Py3) along with the
> *raw_input* function (Py2). Do you really want to inflict "from __future__
> import print_function" on your students?
>
> Best,
> John
>
>


More information about the Edu-sig mailing list