Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'importing': 0.05; 'skip:p 60': 0.07; 'received:internal': 0.09; 'random': 0.14; 'dictionaries': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'portable': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'language': 0.16; 'wrote:': 0.18; 'import': 0.22; 'this?': 0.23; 'subject:Code': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; "doesn't": 0.30; 'characters': 0.30; 'file': 0.32; 'monday,': 0.33; 'received:66': 0.35; 'version': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'from:no real name:2**0': 0.61; 'save': 0.62; 'header :Message-Id:1': 0.63; 'email addr:gmail.com': 0.63; 'different': 0.65; 'skip:p 80': 0.84; '2013,': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:in-reply-to:references:subject:date; s=mesmtp; bh= SjrvOtqZF//BSHEs9h4jUrTvN0c=; b=nxFiynd4Odnu+dAKRpyUEW7E9wKXceQy sHVYHQ8aYJeifypLw2VdumwsdUVEMzSrm6l3R1KRZUlKVmFVYLDHUVVAe6vF2Yji mTywhzsspl5IUpVq17ix5/4PWkKs8Rn8bUBINB6UOxLFkGs3KjkoU8qG/ETncVst 0DJJfyRHMfw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=SjrvOtqZF//BSHEs9h4jUrTvN0c=; b=uh/ +nB/Z+1HB6r7cwqiqPkul5iK8N27LrifLrdV+zNVVv5RsaZRc4yvENTJboQKxjV+ L1upr6lefGzSPU4nHS0nvQ9N7lqYSuFQUS7OrtJzskwJV9gUe6NTSA5xRh/I+KhC rDFLUbjCdyfAHiZzb8TmpkFPGauYCfI6aP+XFNAU= X-Sasl-Enc: Q8VljFvN9JyOWNGiOVQv3Lhx+z/0QgHjiKOY4GWnkHnI 1381247276 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-ce174988 In-Reply-To: <68365e43-498f-4ad2-bac3-6a02938159c7@googlegroups.com> References: <68365e43-498f-4ad2-bac3-6a02938159c7@googlegroups.com> Subject: Re: Code golf challenge: XKCD 936 passwords Date: Tue, 08 Oct 2013 11:47:56 -0400 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381247279 news.xs4all.nl 15912 [2001:888:2000:d::a6]:54034 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56420 On Tue, Oct 8, 2013, at 2:45, sprucebondera@gmail.com wrote: > On Monday, October 7, 2013 8:17:21 PM UTC-10, Chris Angelico wrote: > > print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n"),4)) # 87 > > import random as r > print(*r.sample(open("/usr/share/dict/words").readlines(),4)) # 80 How about this? My version is also portable to systems with different file locations, and localizable to different language dictionaries (Some assembly required). import sys,random print(*map(str.strip,random.sample(list(sys.stdin),4))) # 73 Importing random as r doesn't actually save anything, since " as r" is the same five characters you saved from the one use of it.