K
kj7ny
Hope this hasn't been posted hundreds of times. I have never seen it
before, but could have missed it.
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.
The other day my brain had a functional synapse and I realized I could
just start my interactive session with:
I could then just set up my test variables something like:
And I could then use class type code such as:
I no longer had to remove and then replace all of the self. notation
from my code snippets.
So far I haven't seen why I shouldn't to this. I haven't had any
problems using it, but I haven't used it that much. If there is a
good reason to NOT do it, let me know. Otherwise I hope this helps
anyone who has been annoyed by the same thing.
Thanks,
before, but could have missed it.
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.
The other day my brain had a functional synapse and I realized I could
just start my interactive session with:
I could then just set up my test variables something like:
And I could then use class type code such as:
I no longer had to remove and then replace all of the self. notation
from my code snippets.
So far I haven't seen why I shouldn't to this. I haven't had any
problems using it, but I haven't used it that much. If there is a
good reason to NOT do it, let me know. Otherwise I hope this helps
anyone who has been annoyed by the same thing.
Thanks,