[Tutor] when is a generator "smart?"

Marc Tompkins marc.tompkins at gmail.com
Mon Jun 3 02:23:38 CEST 2013


On Sun, Jun 2, 2013 at 9:56 AM, Jim Mooney <cybervigilante at gmail.com> wrote:


> I still sometimes type input instead of that annoying raw_input and get a
> weird error.


Here's a nifty tip to get around that - and to eliminate one more thing
you'd have to change later, if you switch back to 3.  Put this near the top
of your code (before any calls to input()):
try:
    input = raw_input
except NameError:
    pass

Now you can just use input(), and it will have the 3.x behavior in either
version.

I'll be glad when this all settles out, but Py 3 has been out awhile and an
> awful lot seems to only be for 2.7
>

I suspect it's going to be like this for a while yet.  The differences
between 2.x and 3 _seem_ superficial, but some of them are pretty
fundamental - so packages that do anything non-trivial really need major
rewrites, and then they need to be maintained for both versions.  It's sort
of analogous to writing a native iOS app, and porting it as a native
Android app, and maintaining both.  It can be done, but it requires a lot
of effort and usually more than a one-man dev team.

I saw a quote a long time ago; I'd love to attribute it properly, but...:
"God created the world in just seven days.  But then, He had no installed
base."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130602/411c13a0/attachment-0001.html>


More information about the Tutor mailing list