Should Python raise a warning for mutable default arguments?

L

Lie

-0 from me. I'd rather feature it more prominently in the tutorial, a
section "The five most common pitfalls" or something like that.


A check at compilation time for list literals would catch 90 % of the cases.
The warning would be targeted at newbies after all. It might still be a
source of confusion when they try to import someone else's code that uses
mutable defaults intentionally.

-1. I think, as many people before me has said, we should treat
programmers as an adult[1], and doesn't try to babysit them by giving
a warning, or worse as an exception. But I do agree that python should
have something like -Wall, where programmers are warned of all
potential problems.

[1] Anyway, you spent your time being a newbie only for a very short
time.
 
C

castironpi

1. When you print spurious warnings, the overall effectiveness of the
warning system is diminished.  People start to ignore them, either by
disabling them or by mentally tuning out.  This in turn makes people
less likely to notice if a real warning is printed.

Carl Banks

Question: what is real warning?
 
C

castironpi

  Don't  MAKE ME  have to tell you  AGAIN !!!!

Two black eyes. Haa haa. My question comes from: "less likely to
notice if a real warning is printed." And this one is a real one, is
my point.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top