Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'val': 0.07; 'python': 0.09; 'brackets': 0.09; 'collections': 0.09; 'dict': 0.09; 'loop.': 0.09; 'cc:addr:python-list': 0.10; 'stored': 0.10; 'anyway': 0.11; '"from': 0.16; '(2,': 0.16; '3):': 0.16; 'wrote:': 0.17; 'library,': 0.17; 'sort': 0.21; 'import': 0.21; 'explicit': 0.22; 'install,': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'format,': 0.27; 'this?': 0.28; '(new': 0.29; 'key,': 0.29; 'install': 0.29; 'file': 0.32; 'could': 0.32; 'print': 0.32; 'subject:data': 0.33; 'version': 0.34; 'pm,': 0.35; 'something': 0.35; 'subject:: ': 0.38; 'nothing': 0.38; 'received:192': 0.39; 'called': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'first': 0.61; 'policy': 0.62; 'email addr:gmail.com': 0.63; 'choose': 0.65; 'results': 0.65; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; '2.7.': 0.84; 'dict.': 0.84; 'matters.': 0.84; 'responses': 0.93 Date: Thu, 09 Aug 2012 17:23:30 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: giuseppe.amatulli@gmail.com Subject: Re: no data exclution and unique combination. References: <864b0104-daa8-4ea5-8003-6cfaab19fdea@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:c6AzIMsF+NEH/N5ucfoEFU64uPBS54OJe1XCNu0QmSA DRYrTEWNBoW120aPxtYgmEmqLTkmofQ2kEZbafGC/XKMVvYrIN eo7etZfiWbrWUPFCWPKRUNNwcUCwXj7LNu68kOC7W1l1Ak2cgh +EXdcEFzO9fHu5NbbL9dMCabd3oWzkj6q2u40GPIqY8v7fo2so 3tfRfzp6fsyv5g571l8FlnQKlvjHk1GFFNhVFZSzEOEuL/ork5 f7O0WLldd5ZtgvyzNfXC2kN2crJRAKoaSXdxdcaWUEmucY7pHw q1gwb2qR93I5xw4io8mVgg6m3Ft7eokM9ywOJ5wWr1X87whpA= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: d@davea.name 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344547435 news.xs4all.nl 6986 [2001:888:2000:d::a6]:34690 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26815 On 08/09/2012 04:06 PM, giuseppe.amatulli@gmail.com wrote: > > > print unique > {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} > > I choose this solution because i could not install "from collections import Counter". Nothing to install, at least for Python 2.7. collections is in the standard library, and Counter is in collections (new in version 2.7) > Anyway how i can print to a file the unique results without the brackets and obtain something like this? > 4 5 1 > 5 4 1 > 4 4 2 > 2 3 1 > 4 3 2 > > To print out a dict in an explicit format, you want a loop. for key, val in unique.items(): print key[0], key[1], val Note that you cannot guarantee the order they will print out, once stored in a dict. You may want to sort them, or otherwise order them if it matters. Note I added my responses after the parts of your message that I was quoting. To put the response first is called top-posting, and against policy here. -- DaveA