[Python-bugs-list] [ python-Bugs-444683 ] IDLE starts too late to enable "yield"

noreply@sourceforge.net noreply@sourceforge.net
Thu, 26 Jul 2001 06:16:39 -0700


Bugs item #444683, was opened at 2001-07-25 22:27
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=444683&group_id=5470

Category: IDLE
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Guido van Rossum (gvanrossum)
>Summary: IDLE starts too late to enable "yield"

Initial Comment:
In attempting to test the use of the new generators,
it seems that IDLE is too far into its operation to
allow "yield" with something like:
    from __future__ import generators
It would be nice to know how to enable it in
IDLE.


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-26 06:16

Message:
Logged In: YES 
user_id=6380

A simple solution would be to add the future statement to
codeop.py, but of course that has other disadvantages.


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2001-07-26 04:53

Message:
Logged In: YES 
user_id=6656

I've come up with a way to do this.

It's a bit gross, although it does seem to work:

[mwh@starship src]$ ./python Lib/code.py 
Python 2.2a0 (#1, Jul 26 2001, 07:37:26) 
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> yield 1
<string>:1: Warning: 'yield' will become a reserved keyword in the future
<string>:1: Warning: 'yield' will become a reserved keyword in the future
<string>:1: Warning: 'yield' will become a reserved keyword in the future
  File "<console>", line 1
    yield 1
          ^
SyntaxError: invalid syntax
>>> from __future__ import generators
>>> yield 1
SyntaxError: 'yield' outside function
>>> 

(I can't test it in Idle 'cause I'm on a dial-up connection to the starship)

Anyway, see it here:

http://starship.python.net/crew/mwh/hacks/codeop-hack.diff

As well as the inherent unpleasantness, adding this global state to 
codeop.py sucks rather, too.  But doing a better job would mean creating 
some kind of object interface and then getting Idle to use it, and I'm 
too lazy (especially if the idea is going to get thrown out anyway).


----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-07-25 23:02

Message:
Logged In: YES 
user_id=31435

Yes, this is a *general* issue with the future statement, 
and explained in the future-statement PEP.  It's not really 
IDLE's problem (neither the cause nor the cure); it's a 
problem for all simulated (non-native) shells, including 
doctest.py.


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=444683&group_id=5470