annoying behavior

Jeremy Jones zanesdad at bellsouth.net
Tue Sep 28 22:20:58 EDT 2004


Steve Holden wrote:

> elbertlev at hotmail.com wrote:
>
>> ----- Original Message -----
>> From: "Jeremy Jones" <zanesdad at bellsouth.net>
>> To: "Elbert Lev" <elbertlev at hotmail.com>
>> Cc: <python-list at python.org>
>> Sent: Tuesday, September 28, 2004 1:13 PM
>> Subject: Re: annoying behavior
>>
>> Jeremy!
>>
>> Sure it would be nice if a the interpreter would give a warning before
>> really instantiating the instance of class foo (at least in "debug" 
>> mode).
>> In my case the error happened after the program ran about 30 minutes. 
>> I do
>> not think this is impossible.
>
>
> If not thinking something impossible actually made it possible then it 
> would be possible for me to ignore this thread rather than responding 
> to it.
>
> Next you'll be asking us to modify the compiler so it produces an 
> error if someone feeds it a program that never terminates.
>
> If your program ran for 30 minutes before this quite-obvious bug 
> appeared then I should suggest you do some serious reading on the 
> subjects of unit-testing and test-first programming.
>
> Alternatively, look for a language with DWIM-mode :-)
>
> regards
>  Steve

I'm going out on a limb here, but is it _possible_ that you imported the 
module that contained the offending class, then 30 minutes later an 
instance of said offending class was created?  Here's your response to 
Daniel Dittmar:

I think, it would be good, if some sort of warning is given during
import, but not during instantiating the instance of the class. At
least in a "debug" mode. What really did happen: the bug was reported
after the scrip was running for 30 minutes. PyCheck finds it
immediatelly. Why not to do the same kind of check in the interpreter?

Here, you're complaining about no warning being given at import.  This 
error would not have been manifest at import time, but at instantiation 
time.  And to your point, "It would be nice for the interpreter to give 
a warning before really creating an instance of the class, at least in 
debug....".... I recommend that you take Steves advice on unit testing.  
Or, you could put try: except: blocks around every instance of any class 
you create :-)  No, it is _not_ impossible for the interpreter to do 
that, but what all do you want it to check?  Maybe I want it to call all 
of my methods with some parameters specified somehow in docstrings and 
make sure no errors occur.  What you're asking is really general.  Too 
general, I think, for new functionality to be placed in the 
interpreter.  Thus Steve's recommendation for unit testing.  If you 
write good unit tests, there's your verification in "debug" mode.  You 
run your tests as you're developing.  That way, you can target your 
specific needs and you don't pay _any_ penalty at runtime.

Jeremy




More information about the Python-list mailing list