On 03/26/2013 05:52 PM, Lucas Meneghel Rodrigues wrote:
You forgot to fix the places in qemu_vm that were using the constants
you ripped off the code... I've fixed the commit and it looks like this:


commit d934f5c3ea2b8aa4c1f88f602214cf44ba49f18d
Author: Chris Evich <[email protected]>
Date: Tue Mar 26 11:05:00 2013 -0400

virt: Timeout Cleanup

eh?

timeout=CREATE_TIMEOUT

timeout=virt_vm.BaseVM.CREATE_TIMEOUT

Ahh, you're right! Class attributes (even if inherited) don't exist at method definition time (and class definition isn't finished yet). I see the mistake now, tricky! I'm surprised pylint didn't catch that. My bad!


Hmm, so then (as a general practical python lesson learned) I can see attaching "constants" to a class definition (as a general pattern) maybe not such a great idea (they easily become non-constants).

i.e. There's a "flip" from constant to instance attribute on creation which might not be obvious from the outside (if they're understood as constants - i.e. the capital name).

Though there's probably other ways to do it. One idea could be to move the actual constant outside the class, then initialize a real class attribute from the constant. i.e.


_CONSTANT = "foo"
class bar(object):
    nonconstant = _CONSTANT
    ...


That way the two meanings aren't mingled together.

Hmm, learn something new every day :D

--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214

_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel

Reply via email to