new in programing

James Stroud jstroud at mbi.ucla.edu
Fri Dec 9 19:53:58 EST 2005


Cameron Laird wrote:
> In article <mailman.1914.1134158780.18701.python-list at python.org>,
> Mike C. Fletcher <mcfletch at vrplumber.com> wrote:
> 
>>Python iterates over "things" (objects), of which integer numbers are 
>>just one possible choice.  The range built-in command produces ranges of 
>>integers which are useful for tasks such as this.

Cameron Laird wrote:

 > In article <mailman.1914.1134158780.18701.python-list at python.org>,
 > Mike C. Fletcher <mcfletch at vrplumber.com> wrote:
 >
 >> Python iterates over "things" (objects), of which integer numbers are just 
one possible choice.  The range built-in command produces ranges of integers 
which are useful for tasks such as this.
 >>

[...clip (something that begs of recursion)...]

 > I don't think the list comprehension helps, in this case--although
 > it hints at the temptation of an eval-able expression which is briefer.  More 
on that, later.

I noticed my last one had duplicates. I have wasted an embarrassingly large 
amount of time fixing it:

def do_something(*args):
   print args

def do_deeply(first, depth, lim, inc, doit=True, *args):
   if depth < lim:
     do_deeply(first+inc, depth+inc, lim, inc, False, *args)
   if first <= depth:
     do_deeply(first+inc, depth, lim, inc, True, *args + (first,))
   elif doit:
     do_something(*args)

do_deeply(first=1, depth=3, lim=4, inc=1)



More information about the Python-list mailing list