🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #8394

Re: sortowanie slownika (dict)

#8394
From: Przemek Wiśniewski
Date: Tue, 26 Apr 2005 12:19
78 lines
2436 bytes
Adam Przybyla napisał(a):
> [ PorkOne ] <porkone@wp.pl> wrote:
> 
>>William wrote:
>>
>>>Użytkownik "[ PorkOne ]" <porkone@wp.pl> napisał w wiadomości
>>>news:d4l7iu$ip6$1@nemesis.news.tpi.pl...
>>>
>>>
>>>>Witam.
>>>>W jaki sposob wylaczyc automatyczne sortowanie slownika? Czy wogole jest
>>>>taka mozliwosc?
>>>
>>>
>>>Jak ci się słownik sortuje ?
>>>
>>>
>>
>>Robie slownik:
>>
>>d = {}
>>d["aaa"] = "xxxx"
>>d["bbb"] = "yyyy"
>>d["ccc"] = "zzzz"
>>
>>i jak dam:
>>
>>print d.keys()
>>
>>to dostane klucze, ale nie w takiej kolejnosci jak wstawilem, czyli nie:
>>
>>aaa, bbb, ccc
>>
>>tylko na przyklad:
>>
>>bbb, ccc, aaa
> 
> gormenghast:/home/adam>python
> Python 2.2.3 (#1, Oct 15 2003, 23:33:35)
> [GCC 3.3.1 20030930 (Red Hat Linux 3.3.1-6)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> 
>>>>x={1:3,7:4,2:777}
>>>>x
> 
> {1: 3, 2: 777, 7: 4}
> 
>>>>x[777]=4
>>>>x[0]=4
>>>>x
> 
> {0: 4, 1: 3, 2: 777, 777: 4, 7: 4}
> 
>>>>x.keys()
> 
> [0, 1, 2, 777, 7]
> 
> cos się nie sortuja maja zupelnei inna strukture;-) Nie musisz się obawiac:) Z powazaniem
> 								Adam Przybyla

Nie wiem czy cie dobrze rozumiem, ale

 >>> hash(1)
1
 >>> hash(2)
2
 >>> hash(3)
3
 >>> hash('1')
1977051568
 >>> hash('2')
2105051955
 >>> hash('3')
-2061914958


-- 
Przemek Wiśniewski
Technical Details
Message-ID: <d4lbk3$e4d$1@gw.magellan.net.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.internetia.pl!not-for-mail
References: <d4l7iu$ip6$1@nemesis.news.tpi.pl> <d4l8pt$ha2$1@inews.gazeta.pl> <d4l9fq$570$1@nemesis.news.tpi.pl> <d4l9rh$6cl$1@nemesis.news.tpi.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.internetia.pl!not-for-mail
From: Przemek Wiśniewski <sdf@fasd.sdf>
Newsgroups: pl.comp.lang.python
Subject: Re: sortowanie slownika (dict)
Date: Tue, 26 Apr 2005 14:19:14 +0200
Organization: Netia Telekom S.A.
Lines: 78
Message-ID: <d4lbk3$e4d$1@gw.magellan.net.pl>
References: <d4l7iu$ip6$1@nemesis.news.tpi.pl> <d4l8pt$ha2$1@inews.gazeta.pl> <d4l9fq$570$1@nemesis.news.tpi.pl> <d4l9rh$6cl$1@nemesis.news.tpi.pl>
NNTP-Posting-Host: gw.magellan.net.pl
Mime-Version: 1.0
X-Trace: nefryt.internetia.pl 1114517955 14477 213.17.131.34 (26 Apr 2005 12:19:15 GMT)
X-Complaints-To: abuse@inetia.pl
NNTP-Posting-Date: Tue, 26 Apr 2005 12:19:15 +0000 (UTC)
In-Reply-To: <d4l9rh$6cl$1@nemesis.news.tpi.pl>
X-Accept-Language: pl, en-us, en
X-Tech-Contact: usenet@internetia.pl
User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324)
X-Server-Info: http://www.internetia.pl/news/
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit