Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47459
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: I used defaultdic to store some variables but the output is blank |
| Date | 2013-06-09 14:46 +0200 |
| Organization | None |
| References | <35dd1554-de27-4209-b62e-6a2968c19d0c@googlegroups.com> <7b40883a-4211-48cc-8db4-2414fa52e23a@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2917.1370782008.3114.python-list@python.org> (permalink) |
claire morandin wrote:
> Thanks Peter, true I did not realize that ercc_contigs is empty, but I am
> not sure how to "populate" the dictionary if I only have one column for
> the value but no key
You could use a "dummy value"
ercc_contigs = {}
for line in open('Faq_ERCC_contigs_name.txt'):
gene = line.split()[0]
ercc_contigs[gene] = None
but a better approach is to use a set instead of a dict:
ercc_contigs = set()
for line in open('Faq_ERCC_contigs_name.txt'):
gene = line.split()[0]
ercc_contigs.add(gene)
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
I used defaultdic to store some variables but the output is blank claire morandin <claire.morandin@gmail.com> - 2013-06-09 03:12 -0700
Re: I used defaultdic to store some variables but the output is blank Peter Otten <__peter__@web.de> - 2013-06-09 13:56 +0200
Re: I used defaultdic to store some variables but the output is blank claire morandin <claire.morandin@gmail.com> - 2013-06-09 05:27 -0700
Re: I used defaultdic to store some variables but the output is blank Peter Otten <__peter__@web.de> - 2013-06-09 14:46 +0200
csiph-web