In article
<[EMAIL PROTECTED]>,
Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Oct 14, 1:36 pm, "David C. Ullrich" <[EMAIL PROTECTED]> wrote:
> > >[...]
>
> > In particular default parameters should work the way the user
> > expects! The fact that different users will expect different
> > things
David C. Ullrich a écrit :
In article <[EMAIL PROTECTED]>,
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
(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
On Sun, 19 Oct 2008 00:56:17 -0700, Paul McGuire wrote:
> On Oct 14, 1:36 pm, "David C. Ullrich" <[EMAIL PROTECTED]> wrote:
...
>> In particular default parameters should work the way the user expects!
>> The fact that different users will expect different things here is no
>> excuse...
>>
> Are yo
On Sun, Oct 19, 2008 at 12:56 AM, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Oct 14, 1:36 pm, "David C. Ullrich" <[EMAIL PROTECTED]> wrote:
>> > Well... How to say.. Is there any chance these people will read anything
>> > *at all* ?
>>
>> No. That's exactly the point! Basic Python is so transpar
On Oct 14, 1:36 pm, "David C. Ullrich" <[EMAIL PROTECTED]> wrote:
> > Well... How to say.. Is there any chance these people will read anything
> > *at all* ?
>
> No. That's exactly the point! Basic Python is so transparent that
> you can start using it without reading anything, just looking at
> a
Steven D'Aprano wrote:
> On Sun, 19 Oct 2008 02:52:52 +, Aaron Brady wrote:
>
>> Steven D'Aprano wrote:
>>
>>> On Sat, 18 Oct 2008 09:17:28 +1300, Lawrence D'Oliveiro wrote:
>>>
In message
<[EMAIL PROTECTED]>,
Aaron "Castironpi" Brady wrote:
> The purpose of a paramet
On Sun, 19 Oct 2008 02:52:52 +, Aaron Brady wrote:
> Steven D'Aprano wrote:
>
>> On Sat, 18 Oct 2008 09:17:28 +1300, Lawrence D'Oliveiro wrote:
>>
>>> In message
>>> <[EMAIL PROTECTED]>,
>>> Aaron "Castironpi" Brady wrote:
>>>
The purpose of a parameter is something that the caller can
Steven D'Aprano wrote:
> On Sat, 18 Oct 2008 09:17:28 +1300, Lawrence D'Oliveiro wrote:
>
>> In message
>> <[EMAIL PROTECTED]>,
>> Aaron "Castironpi" Brady wrote:
>>
>>> The purpose of a parameter is something that the caller can supply, but
>>> doesn't have to. It is not for internal-use-only i
On Sat, 18 Oct 2008 09:17:28 +1300, Lawrence D'Oliveiro wrote:
> In message
> <[EMAIL PROTECTED]>,
> Aaron "Castironpi" Brady wrote:
>
>> The purpose of a parameter is something that the caller can supply, but
>> doesn't have to. It is not for internal-use-only items.
>
> Exactly!
Says who?
U
In message <[EMAIL PROTECTED]>, Steven D'Aprano
wrote:
> On Fri, 17 Oct 2008 23:04:52 +1300, Lawrence D'Oliveiro wrote:
>
>> The right solution, of course, is
>>
>> fns = [(lambda x : lambda : x)(x) for x in range(10)]
>
> Only if by "right solution" you mean "excessively verbose, confusing
In message
<[EMAIL PROTECTED]>,
Aaron "Castironpi" Brady wrote:
> The purpose of a parameter is something that the caller can supply, but
> doesn't have to. It is not for internal-use-only items.
Exactly!
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 17, 6:56 am, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Fri, 17 Oct 2008 23:04:52 +1300, Lawrence D'Oliveiro wrote:
> > In message <[EMAIL PROTECTED]>, Duncan Booth wrote:
>
> >> We already get people asking why code like this doesn't return 3:
>
> > fns = [ lambd
On Fri, 17 Oct 2008 23:04:52 +1300, Lawrence D'Oliveiro wrote:
> In message <[EMAIL PROTECTED]>, Duncan Booth wrote:
>
>> We already get people asking why code like this doesn't return 3:
>>
> fns = [ lambda: x for x in range(10) ] fns[3]()
>> 9
>>
>> ... making this change to default argum
In message <[EMAIL PROTECTED]>, Duncan Booth wrote:
> We already get people asking why code like this doesn't return 3:
>
fns = [ lambda: x for x in range(10) ]
fns[3]()
> 9
>
> ... making this change to default arguments would mean the
> solution usually proposed to the function scopi
On Oct 16, 7:54 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Thu, 16 Oct 2008 12:18:49 -0700, Aaron \"Castironpi\" Brady wrote:
>
> [snip]
>
> >> If Python re-evaluated the default value i=i at runtime, the above
> >> would break.
>
> > Not with a mere extra lambda.
>
> No
On Thu, 16 Oct 2008 12:18:49 -0700, Aaron \"Castironpi\" Brady wrote:
[snip]
>> If Python re-evaluated the default value i=i at runtime, the above
>> would break.
>
> Not with a mere extra lambda.
Not so. It has nothing to do with lambda, lambda just happens to be a
convenient example. Here's
In article <[EMAIL PROTECTED]>,
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> 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 "imp
On Oct 16, 12:23 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Thu, 16 Oct 2008 17:05:40 +1300, Lawrence D'Oliveiro wrote:
> > In message <[EMAIL PROTECTED]>, Steven D'Aprano
> > wrote:
>
> >> On Thu, 09 Oct 2008 01:39:30 -0700, kenneth (a.k.a. Paolo) wrote:
>
> >>> On Oct
On Oct 16, 1:05 am, "Chris Rebert" <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 15, 2008 at 9:43 PM, Aaron Castironpi Brady
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > On Oct 15, 11:33 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> >> Aaron "Castironpi" Brady wrote:
>
> >> [about how default argument behavio
On Thu, 16 Oct 2008 17:05:40 +1300, Lawrence D'Oliveiro wrote:
> In message <[EMAIL PROTECTED]>, Steven D'Aprano
> wrote:
>
>> On Thu, 09 Oct 2008 01:39:30 -0700, kenneth (a.k.a. Paolo) wrote:
>>
>>> On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
>>>
No, it always contains
Chris Rebert:
> Although primitive and likely somewhat flawed, you may find the
> statistics in the "Compatibility Issues" section
> ofhttp://mail.python.org/pipermail/python-3000/2007-February/005704.html
> to be of interest.
I am quite glad to see that I am not the only one that cares for such
On Wed, Oct 15, 2008 at 9:43 PM, Aaron Castironpi Brady
<[EMAIL PROTECTED]> wrote:
> On Oct 15, 11:33 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>> Aaron "Castironpi" Brady wrote:
>>
>> [about how default argument behavior should, in his opinion, be changed]
>>
>> Say what you like. The language i
On Oct 15, 11:33 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Aaron "Castironpi" Brady wrote:
>
> [about how default argument behavior should, in his opinion, be changed]
>
> Say what you like. The language is as it is by choice. Were it, for some
> reason, to change we would then be receiving pos
Aaron "Castironpi" Brady wrote:
[about how default argument behavior should, in his opinion, be changed]
Say what you like. The language is as it is by choice. Were it, for some
reason, to change we would then be receiving posts every week that
didn't understand the *new* behavior.
Sometimes peop
On Oct 15, 11:05 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED]
central.gen.new_zealand> wrote:
> In message <[EMAIL PROTECTED]>, Steven D'Aprano
> wrote:
>
> > On Thu, 09 Oct 2008 01:39:30 -0700, kenneth (a.k.a. Paolo) wrote:
>
> >> On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
>
> >
In message <[EMAIL PROTECTED]>, Steven D'Aprano
wrote:
> On Thu, 09 Oct 2008 01:39:30 -0700, kenneth (a.k.a. Paolo) wrote:
>
>> On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
>>
>>> No, it always contains the default argument because default values are
>>> created just ONE TIME
<
I would just like to add to the discussion that 4as a second year computer
science undergraduate and I noticed the same "issue" with default arguments,
but I was able to figure out the system of how (and why) python does it the
way it does, without having to consult any documentation offline or onl
On Oct 14, 1:50 pm, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> David C. Ullrich a écrit :
>
>
>
> > In article <[EMAIL PROTECTED]>,
> > Bruno Desthuilliers <[EMAIL PROTECTED]>
> > wrote:
snip
> (snip)
snip
> > In particular default parameters should work the way the user
> > expects! The fa
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 tutoria
In article <[EMAIL PROTECTED]>,
Bruno Desthuilliers <[EMAIL PROTECTED]>
wrote:
> David C. Ullrich a écrit :
> > In article
> > <[EMAIL PROTECTED]>,
> > kenneth <[EMAIL PROTECTED]> wrote:
> >
> >> On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
> >>> kenneth wrote:
> the
On Oct 11, 4:41 am, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Fri, 10 Oct 2008 06:20:35 -0700, bearophileHUGS wrote:
snip
> > I have seen professional programmers too use class attributes instead of
> > instance ones...
>
> That's only a mistake if you don't mean to use cla
On Oct 10, 12:30 pm, Duncan Booth <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] wrote:
> >> I don't think simply re-executing the default argument
> >> expression on each call works either: that would confuse at least as
> >> many people as the current system.
>
> > May I ask you why? I think I do
On Fri, 10 Oct 2008 06:20:35 -0700, bearophileHUGS wrote:
>> I don't think simply re-executing the default argument expression on
>> each call works either: that would confuse at least as many people as
>> the current system.
>
> May I ask you why? I think I don't agree, but I am not sure.
x = 1
On Thu, 09 Oct 2008 01:39:30 -0700, kenneth (a.k.a. Paolo) wrote:
> On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
>> kenneth wrote:
>> > the 'd' variable already contains the 'self.d' value of the first
>> > instance and not the default argument {}.
>>
>> > Am I doing some stupid
Chris Rebert:
> The general idea been discussed ad-nauseum on the list several times
> before, including just 2 months ago. See e.g.:
Okay, it can't be fixed then.
Bye and thank you,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
>> I don't think simply re-executing the default argument
>> expression on each call works either: that would confuse at least as
>> many people as the current system.
>
> May I ask you why? I think I don't agree, but I am not sure.
>
My thought (which may well be wrong)
On Fri, Oct 10, 2008 at 4:36 AM, <[EMAIL PROTECTED]> wrote:
> Bruno Desthuilliers:
>> You mean : "to people that don't bother reading the FineManual *nor*
>> searching the newsgroup / ML archives ?"
>
> Are there ways to change how Python3 manages arguments and functions,
> to remove this antifeat
Duncan Booth:
> You can't just copy the default values on every call: you would still get
> people confused by the semantics whether you did a shallow or deep copy or
> as now no copy.
I think I agree.
> I don't think simply re-executing the default argument
> expression on each call works eithe
[EMAIL PROTECTED] wrote:
> Bruno Desthuilliers:
>> You mean : "to people that don't bother reading the FineManual *nor*
>> searching the newsgroup / ML archives ?"
>
> Are there ways to change how Python3 manages arguments and functions,
> to remove this antifeature of Python, avoiding this commo
Bruno Desthuilliers:
> You mean : "to people that don't bother reading the FineManual *nor*
> searching the newsgroup / ML archives ?"
Are there ways to change how Python3 manages arguments and functions,
to remove this antifeature of Python, avoiding this common mistake
done by every newbie?
I do
David C. Ullrich a écrit :
In article
<[EMAIL PROTECTED]>,
kenneth <[EMAIL PROTECTED]> wrote:
On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
kenneth wrote:
the 'd' variable already contains the 'self.d' value of the first
instance and not the default argument {}.
Am I doing
In article
<[EMAIL PROTECTED]>,
kenneth <[EMAIL PROTECTED]> wrote:
> On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
> > kenneth wrote:
> > > the 'd' variable already contains the 'self.d' value of the first
> > > instance and not the default argument {}.
> >
> > > Am I doing som
kenneth a écrit :
On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
kenneth wrote:
the 'd' variable already contains the 'self.d' value of the first
instance and not the default argument {}.
Am I doing some stupid error, or this is a problem ?
No, it always contains the default a
On Thu, Oct 9, 2008 at 1:39 AM, kenneth <[EMAIL PROTECTED]> wrote:
> On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
>> kenneth wrote:
>> > the 'd' variable already contains the 'self.d' value of the first
>> > instance and not the default argument {}.
>>
>> > Am I doing some stupid
On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
> kenneth wrote:
> > the 'd' variable already contains the 'self.d' value of the first
> > instance and not the default argument {}.
>
> > Am I doing some stupid error, or this is a problem ?
>
> No, it always contains the default argu
kenneth wrote:
the 'd' variable already contains the 'self.d' value of the first
instance and not the default argument {}.
Am I doing some stupid error, or this is a problem ?
No, it always contains the default argument because default values are
created just ONE TIME.
http://effbot.org/pyfa
See Pitfall #5 on http://zephyrfalcon.org/labs/python_pitfalls.html
It also applies to dictionaries (and sets, any mutable object really).
On Thu, Oct 9, 2008 at 1:03 AM, kenneth <[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I have encountered this weird problem.
>
> I have a class definition with an
Dear all,
I have encountered this weird problem.
I have a class definition with an __init__ argument 'd'
which defaults to {}. This argument is put in the 'self.d'
attribute at initialization
I create two independent instances of this class; the code
is as follows.
class C:
def __init__(self,
48 matches
Mail list logo