Self in Interactive Interpreter
kj7ny
kj7ny at nakore.com
Sun Apr 6 05:05:47 EDT 2008
On Apr 4, 1:41 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> kj7nywrote:
> > 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>
Didn't know about the
>>> class dummy: pass
option. It makes sense now that I see it. Just hadn't ever tried it,
I guess. Thanks!
With some of my larger applications, it doesn't seem to work well to
try to run the whole thing in the interpreter. At least for me, I am
not a big IDE sort of programmer. I am much more comfortable in vim
and command line stuff. I suppose I should use the IDE more.
I wasn't offering this "tip" as a cure all. It was just an
observation should it be of use to someone out there. However, I
greatly appreciate your improvement on the example I gave. I will use
your class dummy: pass approach from now on.
Thanks,
More information about the Python-list
mailing list