SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Eric F. <ef...@ha...> - 2007年03月26日 06:58:29
The coding guide recommends that any **kwargs dictionary that is passed 
into a function should be copied so that the original is unaffected when 
items are popped off inside the function. I noticed that this is not 
done by pylab functions generated by boilerplate.py, and in fact I don't 
think it is necessary:
In [9]:def test2(**kw):
 ...: first = kw.pop('a')
 ...: print first
 ...: print kw
 ...:
 ...:
In [10]:test2(**kw)
c
{'b': 'd'}
In [11]:kw
Out[11]:{'a': 'c', 'b': 'd'}
Popping the 'a' entry inside the function did not affect the dictionary 
that was passed in; it evidently gets copied automatically.
Am I missing something? Or should I go ahead and strip out the extra 
copies and modify the corresponding advice in CODING_GUIDE?
Eric
From: John H. <jd...@gm...> - 2007年03月27日 01:38:10
On 3/26/07, Eric Firing <ef...@ha...> wrote:
> Popping the 'a' entry inside the function did not affect the dictionary
> that was passed in; it evidently gets copied automatically.
>
> Am I missing something? Or should I go ahead and strip out the extra
> copies and modify the corresponding advice in CODING_GUIDE?
Well, that was certainly a surprise to me -- yep all the copying of
**kwargs can be eliminated and the CODING_GUIDE updated. Thanks for
discovering this and pointing it out!
JDH
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

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