Style/efficiency question using 'in'

davidtmoore at my-dejanews.com davidtmoore at my-dejanews.com
Fri Apr 23 17:17:10 EDT 1999


In article <3720B3B9.98BED320 at earth.ox.ac.uk>,
  Nick Belshaw <nickb at earth.ox.ac.uk> wrote:
> If someone could spare a mo to clarify -
>
> If I do something like :-
>
> ------------------
> def  func1():
>     return 1,2,3,4,5,6,7,8
>
> for x in func1():
>     print x
> ------------------

This may not be appropriate to the problem that you are really trying to
solve, but are you aware of this (range(n) will make your list for you):

>>> range(8)
[0, 1, 2, 3, 4, 5, 6, 7]
>>> for x in range(8):
... 	print x+1
...
1
2
3
4
5
6
7
8
>>>

----
David Moore

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




More information about the Python-list mailing list