About generators

Ben Finney bignose-hates-spam at and-benfinney-does-too.id.au
Mon Apr 26 02:21:03 EDT 2004


On Mon, 26 Apr 2004 06:30:10 GMT, Andrea Griffini wrote:
> I'm new to python and I really like what I've seen so far with just
> one exception; the absence of a nice syntax for ranges of integers.

I'm not sure if you're unaware of the range() builtin:

    for i in range(10):
        print i

Are you saying this isn't a "nice syntax"?  It seems quite
self-explanatory, and doesn't require new syntax.

What is it you don't like about range()?

> [I prefer] having "expr1 ... expr2" returning an iterator from expr1
> to expr2 (second limit included).

If this were to happen, I'd prefer two periods instead of three
(matching previous experience with Pascal and related languages).

-- 
 \     "Every decent man is ashamed of the government he lives under." |
  `\                                               -- Henry L. Mencken |
_o__)                                                                  |
Ben Finney <http://bignose.squidly.org/>



More information about the Python-list mailing list