Steven D'Aprano wrote:
>>> The most common idiom for such a marker is the None value.
>>>
>>
>> Can you provide any firm evidence that using None is more common?
>
>
> Yes, I wrote a quick and dirty script to roughly count the default
> values in the Python 2.3 standard library. Here are my re
On Mon, 20 Feb 2006 08:52:09 +, Duncan Booth wrote:
> Ben Finney wrote:
>
>> Duncan Booth <[EMAIL PROTECTED]> writes:
>>> If you intend to only use the default some of the time, and at other
>>> times pass in a different list, then save the 'default' in the
>>> instance and use a special mark
Ben Finney wrote:
> Duncan Booth <[EMAIL PROTECTED]> writes:
>> If you intend to only use the default some of the time, and at other
>> times pass in a different list, then save the 'default' in the
>> instance and use a special marker value to indicate when you intend
>> the default to be used:
>
Duncan Booth <[EMAIL PROTECTED]> writes:
> If you intend to only use the default some of the time, and at other
> times pass in a different list, then save the 'default' in the
> instance and use a special marker value to indicate when you intend
> the default to be used:
The most common idiom for
Em Sáb, 2006-02-18 às 16:50 +, Duncan Booth escreveu:
> marker = object()
>
> class Test(object):
> def __init__(self):
> self.L = []
>
> def f(self,a, L=marker):
> if L is marker:
> L = self.L
> L.append(a)
> return L
As hasattr(None, "ap
K. Jansma wrote:
> as you can see, the b.f method shares L with a.f.
> How can I avoid this without using eg. self.L in an __init__?
>
You cannot.
If a method argument has a default value then the same default is used
whenever the method is called. If you want each instance to have its own
va
Em Sáb, 2006-02-18 às 17:42 +0100, K. Jansma escreveu:
> How can I avoid this without using eg. self.L in an __init__?
Why not use it? That's how it's meant to be done!
> Thanks in advance,
> Karel.
Cya,
Felipe.
--
"Quem excele em empregar a força militar subjulga os exércitos dos
outros povos