Styling Temporary Code

Shae Erisson shapr at uab.edu
Thu Jun 1 15:52:18 EDT 2000


Pete Shinners wrote:

> int myfunc(int nullargs)
> {
>     int newval = do_fancy_stuff(nullargs);
> cout << "newval = " << newval << endl;
>     return more_fancy(newval);
> }
> 
> ok, in this 5 line example it doesn't really sparkly,
> but when i use it in big sections of code, it can't
> be beat. call it the mark of the beast, chase me with
> pitchforks, i simply love it and i don't want to change!
> 
> now in python this obviously won't work, but i haven't
> been able to settle on a style that works for me yet.
> what do other people use for this "working" code?

The two things I use are assert statements and print

def myfunc(invar)
    assert invar == type(''),'invar in myfunc is not a string!'
    newval = do_fancy_stuff(nullargs)
    print newval
    return more_fanc(newval)

I don't do C, so this may not be an exact translation....

On the other hand, I also use PyUnit, and that often renders this kind
of code moot.
-- 
sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre
   bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt
13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j



More information about the Python-list mailing list