Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'context': 0.07; 'raises': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'wrong,': 0.09; 'python': 0.11; '"list': 0.16; 'indexerror:': 0.16; 'mylist': 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; 'index': 0.16; 'language': 0.16; 'wrote:': 0.18; 'work,': 0.20; '>>>': 0.22; 'python?': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'header:X-Complaints- To:1': 0.27; 'tried': 0.27; 'array': 0.29; 'code': 0.31; 'easier': 0.31; 'too.': 0.31; 'usually': 0.31; '"",': 0.31; 'file': 0.32; 'lists': 0.32; '(most': 0.33; 'table': 0.34; 'problem.': 0.35; 'something': 0.35; '(2)': 0.35; 'but': 0.35; 'error.': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'tell': 0.60; 'identify': 0.61; 'range': 0.61; 'email addr:gmail.com': 0.63; 'show': 0.63; 'provide': 0.64; 'caused': 0.69; 'grow': 0.77 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Array of hash table Date: Fri, 09 Jan 2015 08:55:37 +0100 Organization: None References: <05c22fd5-bfae-4e09-9894-341f468e08dc@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bd9f27.dip0.t-ipconnect.de User-Agent: KNode/4.13.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 88 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1420790268 news.xs4all.nl 2850 [2001:888:2000:d::a6]:50523 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83411 jyoti690saini@gmail.com wrote: > Hello, > > Can any one tell me how to create > graph={ > "nodes": [ > { > "id": "n0", > "label": "A node", > "x": 0, > "y": 0, > "size": 3 > }, > { > "id": "n1", > "label": "Another node", > "x": 3, > "y": 1, > "size": 2 > }, > { > "id": "n2", > "label": "And a last one", > "x": 1, > "y": 3, > "size": 1 > } > ], > "edges": [ > { > "id": "e0", > "source": "n0", > "target": "n1", > "label" : "dfghujikoi" > }, > { > "id": "e1", > "label" : "dfghujikoi", > "source": "n1", > "target": "n2" > > }, > { > "id": "e2", > "source": "n2", > "target": "n0", > "label" : "dfghujikoi" > } > ] > } > > using python? > > its like a hash table and value is an array of hash table ? > I tried but it was giving error of "List out of index" . (1) Was that something like >>> [][1] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range ? Please always copy and paste the traceback, don't rephrase. (2) Show us the code that caused the error. If you provide some context it is easier for us to identify your problem. But if I were to guess: are you coming from a language where lists grow automatically? In Python they don't. Instead of mylist = [] for i in range(3): mylist[i] = 42 # WRONG, raises IndexError you usually write mylist = [] for i in range(3): mylist.append(42) though in this particular case mylist = [42] * 3 would work, too.