From owner-freebsd-questions@FreeBSD.ORG Wed Aug 20 17:18:07 2008 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29B35106567A for ; Wed, 20 Aug 2008 17:18:07 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 93E538FC1B for ; Wed, 20 Aug 2008 17:18:06 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.2/8.14.2) with ESMTP id m7KHI4qs051088; Wed, 20 Aug 2008 19:18:04 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.2/8.14.2/Submit) id m7KHI3SJ051087; Wed, 20 Aug 2008 19:18:03 +0200 (CEST) (envelope-from olli) Date: Wed, 20 Aug 2008 19:18:03 +0200 (CEST) Message-Id: <200808201718.m7KHI3SJ051087@lurza.secnetix.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG, andrewlylegould@gmail.com In-Reply-To: X-Newsgroups: list.freebsd-questions User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.3-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Wed, 20 Aug 2008 19:18:04 +0200 (CEST) Cc: Subject: Re: Python script for configuring wifi hot spots on FreeBSD X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-questions@FreeBSD.ORG, andrewlylegould@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Aug 2008 17:18:07 -0000 Andrew Gould wrote: > [...] > 2. I store data in Python dictionaries. When I display the > dictionaries, the numbered options are not in order and I can't > figure out how to sort them. This appears to be a cosmetic > issue only; but it still bothers me. Python dictionaries aren't ordered. If you need to retrieve the items of a dictionary in a particular order, there are several ways to do that. For example, you can use the keys() method to get a list of the keys in the dictionary, and then apply the sort() method or the sorted() function to that list: my_dict = {"foo": 42, "bar": 17, "baz": 83, "hurz": 55} for key in sorted(my_dict.keys()): print key, my_dict[key] Or: for key, value in sorted(my_dict.items()): print key, value > I have attached the script -- it is only 4KB. I didn't see it. Maybe the mailing list software removed it. I suggest you upload it somewhere and tell us the URL. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "Emacs ist für mich kein Editor. Für mich ist das genau das gleiche, als wenn ich nach einem Fahrrad (für die Sonntagbrötchen) frage und einen pangalaktischen Raumkreuzer mit 10 km Gesamtlänge bekomme. Ich weiß nicht, was ich damit soll." -- Frank Klemm, de.comp.os.unix.discussion