[Tutor] when is a generator "smart?"

Jim Mooney cybervigilante at gmail.com
Mon Jun 3 20:13:54 CEST 2013


On 3 June 2013 07:22, Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:

> If you put "from __future__ import print_function" at the top of your
> module you can use the same print function in Python 2.6/2.7 and 3.x.
> I recommend doing this rather than bothering with the 2.x print
> statement.

Using Python 2.7 on Windows 7

That's handy. When I went backward from 3.3 to 2.7, one of the few
things I missed at my level was end= and sep= in print()  .format()
was already backported since I'd learned that. I do like it .format()
better unless you get too fancy with those {}s. I dislike the % format
for some reason. It just looks ugly to me. And as it says in  first
sentence of The Zen of Python from this.py: "Ornhgvshy vf orggre guna
htyl."

As a programming exercise I've been trying to translate Ancient
Pythonaic back to English, but I don't follow Tim Peter's obfuscated
little program yet. Ancient Pythonaic will probably never rival
Klingon ;')

Ah, question just came up. Since I have two pys, when a module is
ported from 2.7 to 3.2 does it always have a different name? If the
names are the same i can see where I can get confused with a pip
install. Unless it is true that if I use pip-3.3 it will always
install a 3.3 module, and if I use pip-2.7 it will always install a
2.7 module. I'd get rid of Py 3.3 for now to avoid confusion, but at
some point, since a lot has not been ported to 3.3 and my second Lutz
book uses 3.3 exclusively, I'll probably need them both anyway. Or
I'll get around to installing virtual environments. But I've already
done too much extraneous fooling around when I should be learning more
Py. Enough with setting up my environment and editors, already. I'm
sick of it.

I'm done with editor tryouts. Wing 101 is just fine but 101 won't do
two Pys without constant changing every time. The pro version will and
it's on my buy list. I judge a restaurant by it's coffee, and so far
of all the editors I tried, Wing is the most intuitive and least
annoying for Py, and it's thoughtful even on small things, like
needing only one dropdown to comment out a block, while others needed
two. That counts if you use commenting-out and print() as the poor
man's debugger. I was hot to have a debugger but once I learned it I
haven't used it since ;')  commenting-out, print(), staring-at, and
getting a cup of coffee seem to work best for now. Maybe later, too.
I'm beginning to feel that if it's longer than a page and looks like
it needs a debugger, it needs breaking up so it doesn't look that way.
My brain can only hold so much before becoming fozzled, and I have a
terrible memory.

Jim


More information about the Tutor mailing list