Self in Interactive Interpreter

Fredrik Lundh fredrik at pythonware.com
Fri Apr 4 16:41:04 EDT 2008


kj7ny wrote:

> For years it has been a slight annoyance that every time I wanted to
> test a snippet of code from a class by running it in the interactive
> interpreter, I had to remove all of the self. instances from the
> code.  After I got it working correctly, I had to put all the self.'s
> back into the code to put it back into my class.

wouldn't it be a lot easier to test your code by importing the module 
containing it into the interactive interpreter?

>>>> class dummy:
>>>>     def __init__(self):
>>>>         pass

or, shorter:

   >>> class dummy: pass

</F>




More information about the Python-list mailing list