Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47459

Re: I used defaultdic to store some variables but the output is blank

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'column': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'empty,': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'set()': 0.16; 'value"': 0.16; 'wrote:': 0.18; 'header:User- Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'subject:some': 0.31; 'subject:the': 0.34; 'could': 0.34; 'but': 0.35; 'thanks': 0.36; 'to:addr:python-list': 0.38; 'realize': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'skip:o 30': 0.61; 'claire': 0.84; 'peter,': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: I used defaultdic to store some variables but the output is blank
Date Sun, 09 Jun 2013 14:46:44 +0200
Organization None
References <35dd1554-de27-4209-b62e-6a2968c19d0c@googlegroups.com> <7b40883a-4211-48cc-8db4-2414fa52e23a@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084bc0a.dip0.t-ipconnect.de
User-Agent KNode/4.7.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2917.1370782008.3114.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1370782008 news.xs4all.nl 15869 [2001:888:2000:d::a6]:35898
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:47459

Show key headers only | View raw


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 | NextPrevious in thread | Find similar | Unroll thread


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