Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.04; 'subject:file': 0.07; '"w")': 0.09; '__future__': 0.09; 'brackets': 0.09; 'cc:addr:python-list': 0.10; 'advance': 0.10; 'aug': 0.13; '(2,': 0.16; '3):': 0.16; 'benjamin': 0.16; 'received:209.85.161.174': 0.16; 'semicolon': 0.16; 'wrote:': 0.17; 'import': 0.21; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'testing': 0.24; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'this?': 0.28; 'url:mailman': 0.29; 'url:python': 0.32; 'file': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'hi,': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'header:Received:5': 0.40; 'url:mail': 0.40; 'august': 0.66; "how's": 0.71; 'dict()': 0.84; 'oscar': 0.84; 'yours': 0.88 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=8H+fTLRHNPfUBWlG1lK0aLKSuzHz418tTee2809hhUY=; b=SgJKKhoWQSb68Gh6I4eydHzBqRRwkJ2mulj2X1eojX0CoNuX5WIAtHMXi18qTvJk1b z4BC845kmddN4YpHtJHw5ibLo8rC43rKDCoqlbH87oL0QZ6IoRi72jNqRbi/vODm2Mqz JWQnM7T5SHH+IdmwDXXlXI4I2OTDoeG+XDuObZXZzXTRFKVWa2nfKMj307INJehj1QRP y3t67SERfdctBtwnptKrKfUzEj7GQ1wG6nabknVmBHCIRoBqhlaD7x8dEnhTb9RwcUzz nacA0ph63keKqfmiWMr5jk/XPyoQdkEpdhifMyvS7wzbMijJ2cobzwSeW9a5nirGKaaY ycCA== MIME-Version: 1.0 In-Reply-To: References: <930ab3d8-4ab9-446d-9970-ee811eb70a44@googlegroups.com> Date: Thu, 9 Aug 2012 15:35:54 -0500 Subject: Re: save dictionary to a file without brackets. From: Giuseppe Amatulli To: Oscar Benjamin Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344544557 news.xs4all.nl 6977 [2001:888:2000:d::a6]:37837 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26809 thanks for the fast replies my testing were very closed to yours but i did not know how On 9 August 2012 15:25, Oscar Benjamin wrote: > > On Aug 9, 2012 9:17 PM, wrote: >> >> Hi, >> I have a dict() unique >> like this >> {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} >> and i want to print to a file without the brackets comas and semicolon in >> order to obtain something like this? >> 4 5 1 >> 5 4 1 >> 4 4 2 >> 2 3 1 >> 4 3 2 >> Any ideas? >> Thanks in advance > > How's this? > > from __future__ import print_function > > output = open("out.txt", "w") > > for (a, b), c in d.items(): > print(a, b, c, file=output) > > output.close() > > Oscar. >> -- >> http://mail.python.org/mailman/listinfo/python-list -- Giuseppe Amatulli Web: www.spatial-ecology.net