[Tutor] A slight bug in IDLE
Jim Mooney
cybervigilante at gmail.com
Sun Jul 14 01:29:35 CEST 2013
Dave Angel <davea at davea.name>
You still don't understand. If you write a module and I import it, then
> other imports BY ME don't affect your module. Whether it's a __future__ one
> or not. My import affects my global namespace, not yours. My compile-time
> switches affect my divide, not yours. Same thing.
>
Ah, clarity. This namespace stuff is cool, but it takes getting used to.
However, it makes perfect sense that I never want to alter the original
intent of the programmer of the module I'm importing, by clobbering his
names.
Where I got confused is I'm importing a module with a manual input, then
renaming the input function to a generator function in my program , so I
can bypass manual input and feed the module tons of data. That works fine,
but I didn't follow how the imported module code could see that it should
go to my generator function instead of the manual input function, unless I
was changing the imported module in some way. But it's now clear I'm not.
Which brings up a question. I finally settled on Python 2.7 for various
reasons, but find some 3.3 things useful. Generators are one-off and input
is one-off, so they match well for testing, for instance. I checked the
docs and I don't see many __future__ imports. Are these all there are, or
are there other useful ones that are better hidden? - nested_scopes,
generators, division, absolute_import, with_statement print_function
unicode_literals
I'm not importing them all, just what seems useful to me at this point, and
renaming raw_input, so my 2.7 is kind of 3.3ish. But is there anything I
missed or any problems I'm unaware of in what will be my standard header,
below?
#Using Python 2.7 on Win 7
from __future__ import generators, division, with_statement, print_function
import sys
if int(sys.version[0]) < 3: input = raw_input
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130713/805f4c5a/attachment.html>
More information about the Tutor
mailing list