Danny Yoo wrote:
> One small comment: we often don't need to use temporary variables like 
> 'var'.
> 
>     def return_a_list(some_var):
>         some_list = []
>         for i in range(5):
>             some_list.append(some_var + i)
>         return some_list
> 
> Sometimes a temporary variable is useful, and sometimes not.  Here, it 
> seems like it's not too necessary.

some_list is not too necessary either; this is a good place for a list 
comprehension:
def return_a_list(some_var):
   return [ some_var + i for i in range(5) ]

or for that matter
   return range(some_var:some_var+5)

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to