[Python-Dev] dict.supplement() (was Re: list.shift())

Ka-Ping Yee ping@lfw.org
2000年3月18日 10:48:10 -0800 (PST)


On 2000年3月17日 artcom0!pf@artcom-gmbh.de wrote:
>> I think no. But what about this one?:
>> 	# pretend self and dict are dictionaries:
> 	def supplement(self, dict):
> 	 for k, v in dict.items():
> 	 if not self.data.has_key(k):
> 		 self.data[k] = v

I'd go for that. It would be nice to have a non-overwriting update().
The only issue is the choice of verb; "supplement" sounds pretty
reasonable to me.
-- ?!ng
"If I have not seen as far as others, it is because giants were standing
on my shoulders."
 -- Hal Abelson

AltStyle によって変換されたページ (->オリジナル) /