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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.04; 'received:209.85.160.174': 0.07; '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; '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; 'thanks!': 0.26; '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=1ewPaHfN2EKwB0FCsj+Lo5WwDB63iXeK17xys0ato3k=; b=AroxOmrEtPQpNm76/84lMsQkLmnK/ocHKlwjd6Qy7ZGmWY6aebwiy4W9PJA6E2NnOd o39bl0G7j5FXpzIH6a5wrBwVu+967kP/LGLackq3cIt/iIHNEfUupbmeawx12MFg1YzF AukX59wQB8Mc/8zp9zFC1qAtHDbhzV3arwlBkoqPBj8H/rzg6CQmkcwdL33C5fBBlmW2 A+Cg7S5NnMtm30TK/8B7SzkL27hccsMTASed3H69U8xyTA6LBBw6IKeZL4LXva/aK6tk lfgDoOhVt3IgmeV0oykeufL3yoRzLRSoZjbjQWQjdjx8pRHgauTGKh1gPh5K7JI8geMn vjjg== MIME-Version: 1.0 In-Reply-To: References: <930ab3d8-4ab9-446d-9970-ee811eb70a44@googlegroups.com> Date: Thu, 9 Aug 2012 15:38:50 -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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344544732 news.xs4all.nl 6988 [2001:888:2000:d::a6]:41499 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26811 thanks for the fast replies my testing were very closed to yours but i did not know how to print the the number after the semicolon! thanks! 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