Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98886
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Jussi Piitulainen <harvesting@is.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: A Program that prints the numbers from 1 to 100 |
| Date | Mon, 16 Nov 2015 15:39:50 +0200 |
| Organization | A noiseless patient Spider |
| Lines | 20 |
| 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> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx02.eternal-september.org; posting-host="305c68510616a2e7ac08bcd2ff1598bd"; logging-data="28886"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mlz088ot7BZ0SlD8IpAQK7FuYyJ0+psg=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:3XtDtnca1eUFuztqdwFkkYDNiQI= sha1:rMpOhDJ/q0WvjrxDKBOMnkqU5TA= |
| Xref | csiph.com comp.lang.python:98886 |
Show key headers only | View raw
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