On Tue, Oct 8, 2013, at 2:45, sprucebond...@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. -- https://mail.python.org/mailman/listinfo/python-list