[Python-Dev] Re: PEP-317

Raymond Hettinger python@rcn.com
Mon, 9 Jun 2003 21:07:48 -0400


> Btw, just to be clear: in pure Python, deferred instantiation is
> already impossible; implicit instantiation is exactly equivalent
> to explicit.

Almost exactly:

>>> def f():
 raise ValueError, 1

>>> def g():
 raise ValueError(1)

>>> from dis import dis
>>> dis(f)
  2           0 LOAD_GLOBAL              0 (ValueError)
              3 LOAD_CONST               1 (1)
              6 RAISE_VARARGS            2
              9 LOAD_CONST               0 (None)
             12 RETURN_VALUE        
>>> dis(g)
  2           0 LOAD_GLOBAL              0 (ValueError)
              3 LOAD_CONST               1 (1)
              6 CALL_FUNCTION            1
              9 RAISE_VARARGS            1
             12 LOAD_CONST               0 (None)
             15 RETURN_VALUE 



On a separate note, I was experimented with explicit instantiation 
and noticed an oddity with my editor's autocomplete.  Upon typing:

    raise TypeError(

the autocompleter looks up the doc string for TypeError and announces:

    Inappropriate argument type

when you were likely expecting to be prompted for the exception value.
Perhaps the doc string should read like this:

   TypeError([exceptionvalue]) --> Exception for inappropriate argument type.



Raymond Hettinger