Re: [Tutor] declaring list

2006-01-11 Thread Logesh Pillay
A[m] = j choose (m+1) Used [j] = False choose (1) Thanks Logesh Pillay ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] declaring list in python

2006-01-10 Thread Logesh Pillay
] * n = [] I'd prefer not to use dummy values I have no use for. Is there any way? Thanks Logesh Pillay ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] permutations using list comprehensions

2005-05-01 Thread Logesh Pillay
Dear list I was really impressed by this version of quicksort:- def qsort (t): if len (t) == 0: return [] else: return qsort([x for x in t[1:] if x <= t[0]]) + [t[0]] + qsort([x for x in t[1:] if x > t[0]]) I'm trying to produce something of a similar structure to generate the

[Tutor] variable scope in nested functions

2005-04-25 Thread Logesh Pillay
Thanks Kent for your reply. You said This is a limitation of Python's nested scopes. You can't assign to a variable in an enclosing scope. One way to work around this is to use a mutable value like a list in the enclosing scope: def foo (n): counter = [0] def choose (i): if (solution f

[Tutor] variable scope in nested functions

2005-04-24 Thread Logesh Pillay
Hello list I am having trouble with a variable to act as a counter in a nested recursive function which will only occasionally find an answer. Something like a static variable in C. Why does this sort of thing not work? def foo (n): counter = 0 def choose (i): if (solution found):

[Tutor] quicksort using list comprehension

2005-04-09 Thread Logesh Pillay
s strange but I have and idea it (or something similar) worked when I last tried Python a yr or so ago. An earlier version of Python? Logesh Pillay ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor