[Tutor] Help refactoring this code

2011-10-09 Thread D. Guandalino
Hi, in this class many methods share common code. class Foo(object): def m1(self): if self.foo: pass # m1 do something elif self.bar: pass # m1 do something else else: pass # m1 do something different def m2(self): if

[Tutor] Please explain TypeError

2011-08-21 Thread D. Guandalino
Python documentation says: exception TypeError Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch. For example: 'foo' + (1, 2) Traceback (most recent call last): File stdin, line 1,

[Tutor] Please help understanding unittest fixtures

2011-08-21 Thread D. Guandalino
Suppose I have this TestCase class. class C(TestCase): def setUp(): # very time consuming and resources intensive stuffs. pass def test_A(self): pass def test_B(self): pass def test_C(self): pass The unittest docs says: Each instance of the

Re: [Tutor] Please explain TypeError

2011-08-21 Thread D. Guandalino
On 22 August 2011 00:17, Dave Angel d...@davea.name wrote: On 08/21/2011 05:35 PM, D. Guandalino wrote: Python documentation says: exception TypeError Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details