🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Pytania początkującego cz. 1

#28274
From: Jordan Szubert
Date: Thu, 10 Nov 2011 16:08
42 lines
1990 bytes
Dnia 10-11-2011 o 16:41:56 hubert depesz lubaczewski <depesz@depesz.com>  
napisał(a):

> On 2011-11-10, Edek <edek.pienkowski@gmail.com> wrote:
>>> czy tych haszy się do czegoś używa?
>>
>> >>> key1 = (1,2,3)
>> >>> key2 = [1,2,3]
>> >>> d1 = { key1 : 'raz dwa trzy'}
>> >>> d1[key2] = 'lista'
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>> TypeError: unhashable type: 'list'
>> >>>
>
> chyba nie do końca kumam. jaki jest cel robienia klucza w d1 w taki
> sposób?
>
> i powiązane - jak zrobić przypisanie do "dicta w dictcie"?
>
> np. w perlu mam:
>
> $hash->{'klucz'}->{'pod-klucz'} = 123;
>
> jak to zrobić w pythonie?
>
> probowalem:
>>>> d1["a"]["b"]="123"
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   KeyError: 'a'
>
> depesz
>

d1=dict()
d1["a"]=dict()
di["a"]["b"]="123"


-- 
Jordan Szubert
Technical Details
Message-ID: <op.v4qm4hlbhilul8@asus7p.home>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin.stu.neva.ru!xlned.com!feeder7.xlned.com!news2.euro.net!209.197.12.242.MISMATCH!nx01.iad01.newshosting.com!newshosting.com!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
References: <vhsqo8-di8.ln1@depesz.com> <slrnjblpjq.7mn.dozzie@jarowit.net> <3q0to8-r2o.ln1@depesz.com> <j9gos2$ib6$1@node2.news.atman.pl> <4v7to8-ieq.ln1@depesz.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin.stu.neva.ru!xlned.com!feeder7.xlned.com!news2.euro.net!209.197.12.242.MISMATCH!nx01.iad01.newshosting.com!newshosting.com!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
Newsgroups: pl.comp.lang.python
Subject: Re: Pytania początkującego cz. 1
References: <vhsqo8-di8.ln1@depesz.com> <slrnjblpjq.7mn.dozzie@jarowit.net> <3q0to8-r2o.ln1@depesz.com> <j9gos2$ib6$1@node2.news.atman.pl> <4v7to8-ieq.ln1@depesz.com>
Date: Thu, 10 Nov 2011 17:08:31 +0100
MIME-Version: 1.0
From: "Jordan Szubert" <usenet@joru.us.to>
Organization: HELL inc.
Message-ID: <op.v4qm4hlbhilul8@asus7p.home>
User-Agent: Opera Mail/11.52 (Win32)
Lines: 45
NNTP-Posting-Host: 83.26.212.28
X-Trace: 1320941313 unt-rea-a-01.news.neostrada.pl 2200 83.26.212.28:60002
X-Complaints-To: abuse@news.neostrada.pl
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit