[Tutor] more newbie questions

Lloyd Kvam pythontutor@venix.com
Wed, 01 May 2002 09:39:38 -0400


Thanks.  An interesting read.

I think Python2.2 helps greatly on the overflow front. int * int will
now return a long when necessary.  Converting a float to a non-float
still seems to require a test (that I omitted) to choose between long
and int.

Kirby Urner wrote:

> 
>>
>> def combo(n, r=None):
>>         if r is None: r = int(n/2)
>>         assert 0 <= r <= n, "r must be between 0 and n"
>>         return int(fact(n,r)/fact(r))
> 
> 
> Check this post by Tim Peters (archives, edu-sig) for
> an optimized version of combo:
> 
> http://aspn.activestate.com/ASPN/Mail/Message/580860
> 
> Kirby
> 
> 


-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice: 
603-443-6155
fax: 
801-459-9582