Re: Class definition within function

2006-08-02 Thread Tomi Lindberg
Peter Otten wrote: > By the way you get an instance of a different class C every time you call f, > so that > > isinstance(f(), type(f()) > > is False. That I didn't know. Well, that theory won't be seeing much practice I guess. -- Tomi Lindberg -- http://mail

Re: Class definition within function

2006-08-02 Thread Tomi Lindberg
Diez B. Roggisch wrote: > No, its not. Only inside of it. And the question really is: why? Thanks. And no need to worry, the question was intended as fully theoretical. -- Tomi Lindberg -- http://mail.python.org/mailman/listinfo/python-list

Class definition within function

2006-08-02 Thread Tomi Lindberg
it__(self): self.a = 'a' return C() >>> x = f() >>> x.a 'a' >>> y=f.C() Traceback (most recent call last): File "", line 1, in -toplevel- y=f.C() AttributeError: 'function' object has no attr

Re: Dice probability problem

2006-04-05 Thread Tomi Lindberg
mul__ raises an AttributeError with the latter)? Difference between the two methods is slightly unclear to me. Thanks, Tomi Lindberg -- http://mail.python.org/mailman/listinfo/python-list

Re: Dice probability problem

2006-04-05 Thread Tomi Lindberg
s well) knowledge on the subject. I'll study the code you posted, and make further questions if something remains unclear afterwards. Thanks, Tomi Lindberg -- http://mail.python.org/mailman/listinfo/python-list

Re: Dice probability problem

2006-04-04 Thread Tomi Lindberg
if new_sums.has_key(k+f): new_sums[k+f] += sums[k] else: new_sums[k+f] = sums[k] sums = new_sums return sums sums = add_dice({}, d6) sums = add_dice(sums, d6) sums = add_dice(sums, d6) -- code ends -- Thanks, Tomi Lindberg -- http://mail.python.org

Dice probability problem

2006-04-04 Thread Tomi Lindberg
on[x] += 1 else: distribution[x] = 1 # Maps the results with above count function. map(count, results) -- code ends -- Thanks, Tomi Lindberg -- http://mail.python.org/mailman/listinfo/python-list

Re: Unit tests in Leo

2005-04-10 Thread Tomi Lindberg
[EMAIL PROTECTED] wrote: Hello Tomi, I'm not really sure about your question, but concerning unit testing you can do a simple test. No problem. I found the Leo forums at Source Forge and I've already received some answers in there. Thanks for replying though. -- "Nowhere in me is the presence of

Unit tests in Leo

2005-04-08 Thread Tomi Lindberg
I'm quite (or very) new to both unit testing and Leo. I've been trying to get @test nodes to work without success so I'd like to have very simple example. So, if I have a @file with the following content... def divide_by_two(x): return x/2 ...and I'd like to write a @test node that checks wh