David C. Ullrich a écrit :
In article <[EMAIL PROTECTED]>,
Bruno Desthuilliers <[EMAIL PROTECTED]>
wrote:
David C. Ullrich a écrit :
(snip)
Seems to me that people often site the "important warning" in
the tutorial. Of course there's no reason anyone would bother
going through the tutorial
Indeed. No reason at all.
- just for fun I looked in the
official Python Reference Manual to see whether they're explicit
about this or require the reader to figure it out from something
else they say.
There's a section titled "7.6 Function definitions". About halfway
through that section there's a _bold face_ statement
"Default parameter values are evaluated when the function definition is
executed.", followed by an explanation of how that can lead to
the sort of problem above.
But there's no reason to read the reference manual neither.
So I guess it _is_ awfully dangerous. They
Hum... Who are "they", exactly ?
should really explain
this aspect of the language's behavior to people who don't read
the formal definition and also don't work through the tutorial.
You mean : "to people that don't bother reading the FineManual *nor*
searching the newsgroup / ML archives ?"
Yes. Also add "don't read any books".
Indeed.
I think I started with some
book
As far as I'm concerned, I started with the FineManual(tm)'s tutorial.
(snip)
Well... How to say.. Is there any chance these people will read anything
*at all* ?
No. That's exactly the point!
Yeps. But I don't think we derive the same conclusions from that point.
Basic Python is so transparent that
you can start using it without reading anything, just looking at
a few examples.
And immediatly fall into a well-known (and well-documented) "gotcha" -
like forgetting to apply the call operator to function, using mutable
default arguments, using mutable class attributes instead of instance
attributes, etc, etc, etc...
While it has been heavily publicized that Python is easy to get started
with - which, AFAICT, seems to still be true for any programmer already
having some experience *and* serious enough to actually _read_ that
fucking manual -, it doesn't mean that, by the virtue of some
extraterrestrial magic, one could master the language just reading a
couple dummy examples. Learning a language requires some home work,
period.
_Because_ of that it's their
who are "they" in this "their" ?
responsibility to
ensure that if you look at a few examples you then have a complete
understanding of the language.
I'm afraid I have to say this is *totally* utopic - except perhaps for
the most braindead and limited language one could imagine. Heck, even
Java - which has explicitely been designed for morons^Mdummies - would
fail this test. How could "a few examples" provide complete
understanding of attribute lookup rules, the descriptor protocol,
metaclasses, iterators, and generator expression - just to name a few ?
Granted, Python is easy to get started with. This doesn't mean anyone
should expect it to work like any language XXX they already know. Every
language has it's own pecularities, every language requires a serious
learning effort, and Python is no exception here.
FWIW, on most programming language-related newgroups, the only answer to
such FAQs would be (at best) a raw RTFM. Not that I'd advertise such a
behaviour here - this newsgroup is mostly newbies-friendly and I
*really* appreciate it to be that way (and happily answer the same 101
questions year after year FWIW), but I really fail to see how anything
more could be done for points that are 1/ clearly documented and 2/
reexplained here month after month.
In particular default parameters should work the way the user
expects! The fact that different users will expect different
things here is no excuse...
If different users expect different - mostly incompatible - things, how
would it be possible to have it working "the way the user expect" ?
Should Python grow some telepathic features to guess the user's
expectations and modifies itself to meet these expectations ?-)
--
http://mail.python.org/mailman/listinfo/python-list