Simple way to catch misspelled Python object attributes?

Viewed 66

When I test/debug my Python code interactively, I'm often sidetracked by accidental mis-spellings - they make me think something is wrong with my code when there isn't.

For example, my object c has a setter for the subframe property:

c.suframe = (0,0,256,256); i = c.snap(verbose=False); print(c._last_transfer_duration); show(i*10)

I expected to get a 256x256 subframe, but because I spelled it suframe instead of subframe, I'd just created an attribute suframe and there was (unexpectedly) no effect on subframing. This was an interactive typo, not a code bug. But I had to notice the misspelling to figure that out.

Is there a simple way to get Python to complain so I notice that the misspelling, instead of silently accepting the new attribute?

(Lint won't help - this is interactive debugging, not code in a file.)

[FWIW, I'm using iPython.]

0 Answers
Related