Writing multiple files with with-context

2011-05-22 Thread Shunichi Wakabayashi
To write onto multiple files on the same time (a number of files are variable), I'd like to code as follows, for example, IF I can do, LIST_LEN = 4 with [ open('list_%d.txt' % i, 'w') for i in range(LIST_LEN) ] as fobjlist: for i in range(1000): fobjlist[random.randrange(LIST_LEN)].write(str

Re: Python sets which support multiple same elements

2011-05-20 Thread Shunichi Wakabayashi
> Many times when I am writing some program in python, I notice that I > could transform my list into set, then use the set methods like union, > intersection, set equality etc. , and it will solve my problem easily. > But then I realize that if I transform my list into set, it will > remove duplic