[Tutor] Alan G Week 10 warmup assignment help
Alan Gauld
alan.gauld at btinternet.com
Sat Apr 2 19:10:54 EDT 2016
On 02/04/16 10:59, Albert-Jan Roskam wrote:
>>> however now pylint is returning:
>>> task_07.py:36: [W0102(dangerous-default-value), iter_dict_funky_sum]
>>> Dangerous default value DATA (__builtin__.dict) as argument
>> I would drop the default value for the parameter.
>> ( I suspect that Python doesn't like DATA as a default value
>> because it means you cant use the function anywhere DATA is
>> not defined. But I'm not sure about that)
>
> I thought this warning was about the use of mutable default arguments
Possibly so, I don't really know why the warning is there.
The "fix" is the same, remove the default value it's not
really helping here.
(if you really wanted it you could use None:
def foo(data = None):
if not data:
data = DATA # use global
...
)
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list