Lawrence D'Oliveiro writes:
> In message , Robert Kern
> wrote:
> > So examining LHS "selectors" is not sufficient for determining
> > immutability.
>
> Yes it is. All your attempts at counterexamples showed is that it is not
> necessary, not that it is not sufficient.
You've got them the wron
On 11/8/10 5:24 PM, Lawrence D'Oliveiro wrote:
In message, Robert Kern
wrote:
On 11/4/10 2:07 AM, Lawrence D'Oliveiro wrote:
In message, Robert
Kern wrote:
On 11/2/10 2:12 AM, Lawrence D'Oliveiro wrote:
In message, Robert
Kern wrote:
"Immutable objects" are just those without an obvious
In message , Robert Kern
wrote:
> On 11/4/10 2:07 AM, Lawrence D'Oliveiro wrote:
>
>> In message, Robert
>> Kern wrote:
>>
>>> On 11/2/10 2:12 AM, Lawrence D'Oliveiro wrote:
>>>
In message, Robert
Kern wrote:
> "Immutable objects" are just those without an obvious API for
>
In article ,
Lawrence D'Oliveiro wrote:
> In message <20101021235138.609fe...@geekmail.invalid>, Andreas Waldenburger
> wrote:
>
> > While not very commonly needed, why should a shared default argument be
> > forbidden?
>
> Because itâs safer to disallow it than to allow it.
The best way t
On Nov 1, 7:30 pm, Lawrence D'Oliveiro wrote:
> In message <20101021235138.609fe...@geekmail.invalid>, Andreas Waldenburger
> wrote:
>
> > While not very commonly needed, why should a shared default argument be
> > forbidden?
>
> Because it’s safer to disallow it than to allow it.
That's why Java
m...@distorted.org.uk (Mark Wooding) wrote:
> And the advantage of all of this typing over ['missing'] is what,
> precisely?
No chance of the sentinel object being accidentally mutated would be
the big one for me, but clarity of intent would be a close second.
--
http://mail.python.org/mailman/l
On Sat, 06 Nov 2010 12:37:42 +, Mark Wooding wrote:
>> > _missing = ['missing']
>>
>> A curious choice for the sentinel value. We're not using Python 1.5 any
>> longer
>
> Two reasons. Firstly, this comes from my Lisp background: making a list
> is the obvious way of producing an unf
Dennis Lee Bieber writes:
> On Sat, 06 Nov 2010 12:37:42 +, m...@distorted.org.uk (Mark Wooding)
> declaimed the following in gmane.comp.python.general:
>
> >
> > Two reasons. Firstly, this comes from my Lisp background: making a
> > list is the obvious way of producing an unforgeable objec
Steven D'Aprano writes:
> On Fri, 05 Nov 2010 12:17:00 +, Mark Wooding wrote:
> > Right; so a half-decent compiler can notice this and optimize
> > appropriately. Result: negligible difference.
>
> Perhaps the biggest cost is that now your language has inconsistent
> semantics: some functio
On Fri, 05 Nov 2010 12:17:00 +, Mark Wooding wrote:
>> #1 Most default values are things like True, False, None, integer or
>> string literals. Since they're literals, they will never change, so you
>> only need to set them once.
>
> Right; so a half-decent compiler can notice this and optimi
Steven D'Aprano writes:
> defaults initialise on function definition (DID)
> defaults initialise on function call (DIC)
>
> I claim that when designing a general purpose language, DID (Python's
> existing behaviour) is better than DIC:
>
> #1 Most default values are things like True, False, None
On Thu, 04 Nov 2010 22:34:07 +, Mark Wooding wrote:
> (Based on experience with other languages, I suspect that evaluating the
> default expression afresh for each call where it's needed would be more
> useful; but it's way too late to change that now.)
Let's call the two strategies:
default
Lawrence D'Oliveiro writes:
> Mediocre programmers with a hankering towards cleverness latch onto it
> as an ingenious way of maintaing persistent context in-between calls
> to a function, completely overlooking the fact that Python offers much
> more straightforward, comprehensible, flexible, an
Lawrence D'Oliveiro writes:
> In message <20101021235138.609fe...@geekmail.invalid>, Andreas
> Waldenburger wrote:
> > While not very commonly needed, why should a shared default argument be
> > forbidden?
>
> Because it’s safer to disallow it than to allow it.
Scissors with rounded ends are saf
On 11/4/10 2:07 AM, Lawrence D'Oliveiro wrote:
In message, Robert Kern
wrote:
On 11/2/10 2:12 AM, Lawrence D'Oliveiro wrote:
In message, Robert
Kern wrote:
"Immutable objects" are just those without an obvious API for modifying
them.
They are ones with NO legal language constructs for mod
In message , Robert Kern
wrote:
> On 11/2/10 2:12 AM, Lawrence D'Oliveiro wrote:
>
>> In message, Robert
>> Kern wrote:
>>
>>> "Immutable objects" are just those without an obvious API for modifying
>>> them.
>>
>> They are ones with NO legal language constructs for modifying them. Hint:
>> if a
Lawrence D'Oliveiro a écrit :
In message <20101021235138.609fe...@geekmail.invalid>, Andreas Waldenburger
wrote:
While not very commonly needed, why should a shared default argument be
forbidden?
Because it’s safer to disallow it than to allow it.
Then there are quite a few python features
Paul Rudin writes:
> Terry Reedy writes:
>
>> Suppose I write an nasty C extension that mutates tuples. What then
>> would be illegal about...
>
> Depends on exactly what we mean by legal. If immutability is part of the
> language spec (rather than an artifact of a particular implementation)
> t
In message
<5f6eceec-1eef-4db7-82a6-e5f553349...@k22g2000yqh.googlegroups.com>, Ian
wrote:
> It seems to me that there is a rather simple case to be made for
> allowing mutable default arguments: instances of user-defined classes
> are fundamentally mutable. Disallowing mutable default arguments
Terry Reedy writes:
> Suppose I write an nasty C extension that mutates tuples. What then
> would be illegal about...
Depends on exactly what we mean by legal. If immutability is part of the
language spec (rather than an artifact of a particular implementation)
then a compiler could assume immut
On Nov 2, 5:59 am, Steven D'Aprano wrote:
> Certainly it's the mediocre programmers who seem to be incapable of
> understanding that Python has no way of telling whether arbitrary objects
> are mutable or not.
>
> def foo(x, y=list()):
> pass
>
> Is y a mutabledefaultor not?
>
> For the benefi
On 11/2/10 2:12 AM, Lawrence D'Oliveiro wrote:
In message, Robert Kern
wrote:
On 2010-11-01 22:31 , Lawrence D'Oliveiro wrote:
In message<8j1seqfa1...@mid.individual.net>, Gregory Ewing wrote:
Steven D'Aprano wrote:
And how does Python know whether some arbitrary default object is
mutable
On 11/2/2010 3:12 AM, Lawrence D'Oliveiro wrote:
"Immutable objects" are just those without an obvious API for modifying
them.
After initial creation ;-)/
They are ones with NO legal language constructs for modifying them.
Suppose I write an nasty C extension that mutates tuples. What then
On Tue, 02 Nov 2010 00:40:17 -0700, Chris Rebert wrote:
> On Fri, Oct 22, 2010 at 12:36 AM, Steven D'Aprano
> wrote:
>> On Thu, 21 Oct 2010 19:53:53 -0700, John Nagle wrote:
This is a common newbie stumbling-block: Don't use lists (or anything
mutable) as default argument values
>>>
>>>
On Tue, 02 Nov 2010 20:12:49 +1300, Lawrence D'Oliveiro wrote about
mutable defaults:
> Which is what we’re talking about
> here: a language construct which is probably one of the top 3 sources of
> grief to Python newbies. And not-so-newbies.
I call bullshit. Maybe you should spend some time o
On Tue, 02 Nov 2010 22:06:40 +1300, Lawrence D'Oliveiro wrote:
> In message , Chris
> Rebert wrote:
>
>> On Fri, Oct 22, 2010 at 12:36 AM, Steven D'Aprano
>> wrote:
>>>
>>> Default mutable arguments have their place
>>
>> But it's a rather obscure one where it is almost never strictly
>> necess
In message , Chris
Rebert wrote:
> On Fri, Oct 22, 2010 at 12:36 AM, Steven D'Aprano
> wrote:
>>
>> Default mutable arguments have their place
>
> But it's a rather obscure one where it is almost never strictly
> necessary to venture.
Mediocre programmers with a hankering towards cleverness la
On Fri, Oct 22, 2010 at 12:36 AM, Steven D'Aprano
wrote:
> On Thu, 21 Oct 2010 19:53:53 -0700, John Nagle wrote:
>>> This is a common newbie stumbling-block: Don't use lists (or anything
>>> mutable) as default argument values
>>
>> That really should be an error.
>
> No it shouldn't. Punishi
In message , Robert Kern
wrote:
> On 2010-11-01 22:31 , Lawrence D'Oliveiro wrote:
>
>> In message<8j1seqfa1...@mid.individual.net>, Gregory Ewing wrote:
>>
>>> Steven D'Aprano wrote:
>>>
And how does Python know whether some arbitrary default object is
mutable or not?
>>>
>>> It doesn'
On 2010-11-01 22:31 , Lawrence D'Oliveiro wrote:
In message<8j1seqfa1...@mid.individual.net>, Gregory Ewing wrote:
Steven D'Aprano wrote:
And how does Python know whether some arbitrary default object is mutable
or not?
It doesn't, that's the whole point.
Of course it knows. It is the one
In message <8j1seqfa1...@mid.individual.net>, Gregory Ewing wrote:
> Steven D'Aprano wrote:
>
>> And how does Python know whether some arbitrary default object is mutable
>> or not?
>
> It doesn't, that's the whole point.
Of course it knows. It is the one defining the concept in the first place
In message <20101021235138.609fe...@geekmail.invalid>, Andreas Waldenburger
wrote:
> While not very commonly needed, why should a shared default argument be
> forbidden?
Because it’s safer to disallow it than to allow it.
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 30 Oct 2010 19:31:53 +1300, Gregory Ewing wrote:
> Steven D'Aprano wrote:
>
>> And how does Python know whether some arbitrary default object is
>> mutable or not?
>
> It doesn't, that's the whole point.
I think we're in violent agreement :)
--
Steven
--
http://mail.python.org/mail
Steven D'Aprano wrote:
And how does Python know whether some arbitrary default object is mutable
or not?
It doesn't, that's the whole point.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Oct 21, 2010 at 7:53 PM, John Nagle wrote:
> On 10/21/2010 2:51 PM, Chris Rebert wrote:
>
>> On Thu, Oct 21, 2010 at 2:36 PM, Sean Choi wrote:
>>
>>> I found two similar questions in the mailing list, but I didn't
>>> understand
>>>
>>> the explanations.
>>> I ran this code on Ubuntu 10.
On Fri, 29 Oct 2010 21:24:23 +1300, Gregory Ewing wrote:
> John Nagle wrote:
>> On 10/21/2010 2:51 PM, Chris Rebert wrote:
>
>>> This is a common newbie stumbling-block: Don't use lists (or anything
>>> mutable) as default argument values
>
>> That really should be an error.
>
> No, it shou
John Nagle wrote:
On 10/21/2010 2:51 PM, Chris Rebert wrote:
This is a common newbie stumbling-block: Don't use lists (or anything
mutable) as default argument values
That really should be an error.
No, it shouldn't. The criterion isn't whether the object is
mutable, but whether you a
On 2:59 PM, Sean Choi wrote:
I found two similar questions in the mailing list, but I didn't understand
the explanations.
I ran this code on Ubuntu 10.04 with Python 2.6.5.
Why do the functions g and behave differently? If calls (3) and
g(3) both exit their functions in the same state,
On Thu, 21 Oct 2010 19:53:53 -0700, John Nagle wrote:
>> This is a common newbie stumbling-block: Don't use lists (or anything
>> mutable) as default argument values
>
> That really should be an error.
No it shouldn't. Punishing everybody for a newbie mistake that nobody
makes twice would
On Thu, 21 Oct 2010 19:53:53 -0700 John Nagle wrote:
> On 10/21/2010 2:51 PM, Chris Rebert wrote:
> > On Thu, Oct 21, 2010 at 2:36 PM, Sean Choi wrote:
> >> I found two similar questions in the mailing list, but I didn't
> >> understand the explanations.
> >> I ran this code on Ubuntu 10.04 with
On 10/21/2010 2:51 PM, Chris Rebert wrote:
On Thu, Oct 21, 2010 at 2:36 PM, Sean Choi wrote:
I found two similar questions in the mailing list, but I didn't understand
the explanations.
I ran this code on Ubuntu 10.04 with Python 2.6.5.
Why do the functions g and behave differently? If cal
On Thu, Oct 21, 2010 at 2:36 PM, Sean Choi wrote:
> I found two similar questions in the mailing list, but I didn't understand
> the explanations.
> I ran this code on Ubuntu 10.04 with Python 2.6.5.
> Why do the functions g and behave differently? If calls (3) and
> g(3) both exit their
I found two similar questions in the mailing list, but I didn't understand
the explanations.
I ran this code on Ubuntu 10.04 with Python 2.6.5.
Why do the functions g and behave differently? If calls (3) and
g(3) both exit their functions in the same state, why do they not enter in
the s
43 matches
Mail list logo