Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.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.058 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'python': 0.11; 'assume': 0.14; '2.7': 0.14; 'imports': 0.16; 'needed!': 0.16; 'module': 0.19; 'seems': 0.21; 'import': 0.22; 'to:name:python- list@python.org': 0.22; 'print': 0.22; 'subject:Code': 0.24; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'received:169.254': 0.32; 'but': 0.35; 'charset:us-ascii': 0.36; 'received:169': 0.37; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'skip:l 50': 0.60; 'to:addr:gmail.com': 0.65; 'safe': 0.72; 'received:10.242': 0.84 From: Nick Cash To: Chris Angelico , "python-list@python.org" Subject: RE: Code golf challenge: XKCD 936 passwords Thread-Topic: Code golf challenge: XKCD 936 passwords Thread-Index: AQHOw/IAzOCgflHl6UG6mv9BNNvk+JnrmR/dgAAIUACAAOYuEA== Date: Wed, 9 Oct 2013 16:07:58 +0000 References: <68365e43-498f-4ad2-bac3-6a02938159c7@googlegroups.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [70.166.238.194] x-forefront-prvs: 0994F5E0C5 x-forefront-antispam-report: SFV:NSPM; SFS:(199002)(189002)(47736001)(56776001)(76796001)(49866001)(47976001)(50986001)(81342001)(66066001)(56816003)(51856001)(80976001)(80022001)(74876001)(54316002)(69226001)(74366001)(83072001)(76786001)(74706001)(59766001)(65816001)(54356001)(76482001)(81816001)(79102001)(77096001)(76576001)(74502001)(74662001)(47446002)(46102001)(77982001)(33646001)(31966008)(81686001)(53806001)(63696002)(81542001)(85306002)(83322001)(74316001)(4396001)(24736002); DIR:OUT; SFP:; SCL:1; SRVR:BY2PR06MB235; H:BY2PR06MB233.namprd06.prod.outlook.com; CLIP:70.166.238.194; FPR:; RD:InfoNoRecords; A:1; MX:1; LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: npcinternational.com 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381334894 news.xs4all.nl 16002 [2001:888:2000:d::a6]:59745 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56502 >> # Python-2, sorry >> import os >> print list(set(open('/usr/share/dict/words')))[os.getpid():][:4] > So that steps by your pid?=20 Not really. It seems to rely on list(set(...)) kinda randomizing order... w= hich is definitely not safe without hash randomization. =20 But this brings up an interesting concept... if we can assume Python 2.7 wi= th the -R flag, or Python 3.3+, I think we do get true pseudo-randomization= out of list(set(...))... which means we can trim some! print(list(set(open('/usr/share/dict/words')))[:4]) No module imports needed! Although it's not as pretty as the original post,= but neither was Roy's. -Nick Cash