Python Forum
Infinate Number Generator
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Infinate Number Generator
#6
Comprehensions can be of the list or generator variety (or for that matter sets and dictionaries in modern Python).

Let me show you what I meant:
Output:
>>> for n in range(10, 0, -2): ... print(n) ... 10 8 6 4 2
It produces the same output as yours, minus the comprehension, minus the lambda. I don't understand what benefit there is to including them when you can skip them without any issues.

EDIT: to clarify, the link I have here says that the original docs didn't say "generate comprehension" but calls for people to use the term. I don't want to dig into this particular terminology argument, but I think it's a reasonable term, I think Ned is a good Python authority, and the rest of my points about indirection still stand.
Reply


Messages In This Thread
Infinate Number Generator - by Larz60+ - Sep-18-2018, 12:43 AM
RE: Infinate Number Generator - by micseydel - Sep-18-2018, 01:28 AM
RE: Infinate Number Generator - by wavic - Sep-18-2018, 03:53 AM
RE: Infinate Number Generator - by micseydel - Sep-18-2018, 03:59 AM
RE: Infinate Number Generator - by wavic - Sep-18-2018, 04:26 AM
RE: Infinate Number Generator - by micseydel - Sep-18-2018, 05:01 AM
RE: Infinate Number Generator - by wavic - Sep-18-2018, 06:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Real Random Number Generator woodturner550 21 2,961 Feb-01-2024, 03:19 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020