`~/.pythonrc' `from __future__ import'
Thomas Bellman
bellman at lysator.liu.se
Mon Jul 8 20:56:30 EDT 2002
Tim Peters <tim.one at comcast.net> wrote:
> [François Pinard]
>> Moreover, this option only works for division, it does not apparently
>> activate generators, for instance.
> Yes, -Q is specific to division, as will become clear if you read the PEP
> 238 "Command Line Option" section.
>> I would rather have all future features available all the time when I
>> write interactively, yet I guess why some people would prefer not.
> There's no way to do that, short of fiddling Python's source code.
Well... At least under Unix there is a way... Put this code in
your ~/.pythonrc:
import fcntl, termios, __future__
dels = "fcntl, termios, __future__, dels, feature, c"
for feature in __future__.all_feature_names:
dels += ", " + feature
for c in "from __future__ import " + feature + "\n":
fcntl.ioctl(1, termios.TIOCSTI, c)
for c in "del "+dels+"\n":
fcntl.ioctl(1, termios.TIOCSTI, c)
(Unfortunately, __future__.all_feature_names isn't in Python 2.1,
so if you need your .pythonrc file to be portable to 2.1 you will
have to filter out the relevant names from dir(__future__). I
leave that as an exercise for the readers.)
Now, I didn't say it was *elegant*, but it seems to work on at
least a couple of Unix dialects.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"The one who says it cannot be done should ! bellman @ lysator.liu.se
never interrupt the one who is doing it." ! Make Love -- Nicht Wahr!
More information about the Python-list
mailing list