Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98876

Re: A Program that prints the numbers from 1 to 100

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: A Program that prints the numbers from 1 to 100
Date Mon, 16 Nov 2015 23:35:37 +1100
Lines 25
Message-ID <mailman.357.1447677345.16136.python-list@python.org> (permalink)
References <ddada022-49a4-418e-85a1-45cd6da015f7@googlegroups.com> <85eea326-406d-4454-8c3a-859f1e464cfc@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 5QtPktih+1UAsfZVwXRdcA8rWFno2mQj7L+JxGWSfh/g==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'received:209.85.223': 0.03; 'sufficient': 0.05; 'bug.': 0.07; 'cc:addr:python-list': 0.09; 'get.': 0.09; 'shame': 0.09; 'bug': 0.10; 'python': 0.10; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:" 100': 0.16; 'skip:n 50': 0.16; 'wrote:': 0.16; 'debugging': 0.18; 'detect': 0.18; 'version.': 0.18; 'project,': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'code.': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'this.': 0.28; 'subject:numbers': 0.29; 'subject:that': 0.29; 'code': 0.30; 'version,': 0.30; 'another': 0.32; 'help,': 0.32; 'received:google.com': 0.35; 'nov': 0.35; 'submitting': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'subject:from': 0.39; 'subject:the': 0.39; 'your': 0.60; 'chrisa': 0.84; 'malicious': 0.84; 'to:none': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=oeqtQSX5/Lvdk9Wqk9BqZKXEU4p2qf8ETMajZ42NSBA=; b=jl+C+wPsAPDbDiCDobExY1GEP+TtVVBbc2DOXSNd2BLJWrp3d3nt32ZEDCMZbC4XG2 H4nSFyz7Jwml244sYqnbZA3AdDTVrmsL9nsulvc0Cj6gENmAwjqcrNtLQXes/bJNvOPv 8B/ihSjjVtDY0FCrUCwzu3VEbeQlPycHaE/ZdMSuBcsbQTLaJ7eciK3QKfETfWU92lKx PwI5Dfx8gEGV7pZ2V0+y3FQrLCeL4aK6YmOLPLcd0atgDSgDl593zsDEEf/DlRm1cV+j sOYZI9QnjEQbN8m1G1lPo0KyyfFSfm0DuVrxLHaPHL6BVpFdubmOJIyksbztgzUtakCd v5nA==
X-Received by 10.107.16.84 with SMTP id y81mr30100562ioi.19.1447677337644; Mon, 16 Nov 2015 04:35:37 -0800 (PST)
In-Reply-To <85eea326-406d-4454-8c3a-859f1e464cfc@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:98876

Show key headers only | View raw


On Mon, Nov 16, 2015 at 10:57 PM,  <harirammanohar159@gmail.com> wrote:
> This would help, but try to write on your own to improve, else you cant make this going long....
>

Here's another version, but with a deliberate bug in it. You may use
this code if and only if your comprehension is sufficient to detect
and correct that bug.

next(filter(None,(print(next(filter(None,reversed(x)))) for x in
enumerate(itertools.islice(itertools.cycle(("Fizzbuzz",0,"","Fizz",not
"Fuzz","Buzz","Fizz",(),bytes(),"Fizz","Buzz",{},"Fizz",False,globals().get(math.pi))),1,101)))),None)

Actually... you know what, I think debugging THAT is a malicious prank
to pull on an experienced Python programmer; plus, if you're caught
submitting that for your project, you deserve all the shame you get.
Trust me, this is NOT good code. Here's the corrected version. It
works, but you do not want to use this.

next(filter(None,(print(next(filter(None,reversed(x)))) for x in
itertools.islice(enumerate(itertools.cycle(("Fizzbuzz",0,"","Fizz",not
"Fuzz","Buzz","Fizz",(),bytes(),"Fizz","Buzz",{},"Fizz",False,globals().get(math.pi)))),1,101))),None)

Enjoy!

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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