REPOST: Re: posting the code - further to odd problem

Hans Nowak wurmy at earthlink.net
Sat Dec 29 03:26:20 EST 2001


Dave Harrison wrote:

> However the packet class code is as follows :
> 
> import string
> pdic = {}
> 
> class Packet:
>         def __init__(self, info):
>                 self.buildDic(info)
> 
>         def buildDic(self, info):
>                 for item in info:
>                         split = string.split(item,"=")
>                         if (len(split) > 1):
>                                 pdic[split[0]] = split[1]
> 
>         def getVal(self, key):
>                 if pdic.has_key(key):
>                         result = pdic[key]
>                 else:
>                         result = ''
>                 return result

It puzzles me how you can do

    for pac in paclist:
        print pac.getVal()

(as quoted from your previous post) and not get an error,
since getVal takes a key as its argument. Which leads me
to suspect that this wasn't actual code. :-)

Anyway, I don't know what kind of items Packet takes
(I got it to work with a list of strings like "a=1" etc),
so I cannot do much there. However, I do notice that
all packet instances share the same dictionary (pdic).
Maybe this has something to do with it? Packet has
no attributes, so I wonder where it takes its value
from.

--Hans

========= WAS CANCELLED BY =======:
Path: news.sol.net!spool0-nwblwi.newsops.execpc.com!newsfeeds.sol.net!newspump.sol.net!nntp1.roc.gblx.net!nntp.gblx.net!nntp.gblx.net!feeder.qis.net!news.maxwell.syr.edu!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r
From: Hans Nowak <wurmy at earthlink.net>
Newsgroups: comp.lang.python
Subject: cmsg cancel <3C2D7CDB.4E3CC449 at earthlink.net>
Control: cancel <3C2D7CDB.4E3CC449 at earthlink.net>
Date: Mon, 31 Dec 2001 02:25:32 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.3C2D7CDB.4E3CC449 at earthlink.net>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news2.kornet.net 1009774804 27193 211.57.49.2 (31 Dec 2001 05:00:04 GMT)
X-Complaints-To: usenet at news2.kornet.net
NNTP-Posting-Date: Mon, 31 Dec 2001 05:00:04 +0000 (UTC)
X-No-Archive: yes
X-Unac4ncel: yes
X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999)

This message was cancelled from within Mozilla.



More information about the Python-list mailing list