Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98886
| From | Jussi Piitulainen <harvesting@is.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: A Program that prints the numbers from 1 to 100 |
| Date | 2015-11-16 15:39 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <lf5fv06rrkp.fsf@ling.helsinki.fi> (permalink) |
| References | <ddada022-49a4-418e-85a1-45cd6da015f7@googlegroups.com> <85eea326-406d-4454-8c3a-859f1e464cfc@googlegroups.com> <mailman.357.1447677345.16136.python-list@python.org> |
Chris Angelico writes:
>
> Here's another version, but with a deliberate bug in it. [- -]
This one recycles fish in a way that looks a bit worrying but it seems
to work. If there's a bug, it's not deliberate. Except stopping at 15 is
deliberate.
from contextlib import contextmanager as fish
from collections import defaultdict as fowl
@fish
def fish(fish):
chip = fowl(str)
chip.update(((fowl(int)[fish],fish),))
yield chip
with fish("Fish") as f, fish("Bush") as b:
print(*("{}{}".format(f[k%3],b[k%5]) or k for k in range(1,16)))
# prints:
1 2 Fish 4 Bush Fish 7 8 Fish Bush 11 Fish 13 14 FishBush
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A Program that prints the numbers from 1 to 100 Cai Gengyang <gengyangcai@gmail.com> - 2015-11-14 09:34 -0800
Re: A Program that prints the numbers from 1 to 100 Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-14 12:49 -0500
Re: A Program that prints the numbers from 1 to 100 BartC <bc@freeuk.com> - 2015-11-14 18:18 +0000
Re: A Program that prints the numbers from 1 to 100 Ammammata <ammammata@tiscalinet.it> - 2015-11-16 11:12 +0000
Re: A Program that prints the numbers from 1 to 100 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-14 18:25 +0000
Re: A Program that prints the numbers from 1 to 100 Steven D'Aprano <steve@pearwood.info> - 2015-11-15 12:39 +1100
Re: A Program that prints the numbers from 1 to 100 harirammanohar159@gmail.com - 2015-11-16 03:57 -0800
Re: A Program that prints the numbers from 1 to 100 Chris Angelico <rosuav@gmail.com> - 2015-11-16 23:35 +1100
Re: A Program that prints the numbers from 1 to 100 Jussi Piitulainen <harvesting@is.invalid> - 2015-11-16 15:39 +0200
Re: A Program that prints the numbers from 1 to 100 Chris Angelico <rosuav@gmail.com> - 2015-11-17 00:43 +1100
csiph-web