On 12/5/2014 3:51 PM, John J Posner wrote:
The defaultdict documentation is confusing on this point. A *long* time
ago, I filed Bug 9536 to improve the doc, but the fix hasn't bubbled to
the surface yet.
Untrue. Your patch 'bubbled to the surface' and got provisionally
rejected in 5 hours an
On Dec 7, 2014 9:33 AM, "Dave Angel" wrote:
>
> On 12/05/2014 03:51 PM, John J Posner wrote:
>>
>> At the beginning of this thread, Ian Kelly said:
>
>
> Since this clearly is intended to be part of the earlier thread, please
make it so by using reply-list or whatever equivalent your email program
On 12/07/2014 11:43 AM, Shiyao Ma wrote:
On Dec 07 at 11:31 -0500, Dave Angel wrote:
Since this clearly is intended to be part of the earlier thread, please make
it so by using reply-list or whatever equivalent your email program has.
Kinda OT. But interested what's the difference between repl
On Dec 07 at 11:31 -0500, Dave Angel wrote:
> Since this clearly is intended to be part of the earlier thread, please make
> it so by using reply-list or whatever equivalent your email program has.
Kinda OT. But interested what's the difference between reply-list and to.
In addition, based on what
On 12/05/2014 03:51 PM, John J Posner wrote:
At the beginning of this thread, Ian Kelly said:
Since this clearly is intended to be part of the earlier thread, please
make it so by using reply-list or whatever equivalent your email program
has.
Not with defaultdict, but you can subcla
At the beginning of this thread, Ian Kelly said:
Not with defaultdict, but you can subclass dict and provide a
__missing__ method directly
To emphasize, you don't need to subclass "defaultdict" -- you need only subclass
"dict" itself:
class MyDict(dict):
def __missing__(self, key):
On Mon, Dec 1, 2014 at 11:29 AM, Larry Martell wrote:
> I spoke too soon:
>
class defaultdictkey(defaultdict):
> ... def __missing__(self, key):
> ... self[key] = self.default_factory(key)
> ...
x = defaultdictkey(lambda k: k)
print x['aaa']
> None
print x['aaa']
> aaa
On Mon, Dec 1, 2014 at 1:36 PM, Ethan Furman wrote:
> On 12/01/2014 10:29 AM, Larry Martell wrote:
>> On Mon, Dec 1, 2014 at 1:19 PM, Ethan Furman wrote:
>>> On 12/01/2014 10:05 AM, Larry Martell wrote:
Is there a way to set the default_factory of defaultdict so that
accesses to un
On 12/01/2014 10:29 AM, Larry Martell wrote:
> On Mon, Dec 1, 2014 at 1:19 PM, Ethan Furman wrote:
>> On 12/01/2014 10:05 AM, Larry Martell wrote:
>>>
>>> Is there a way to set the default_factory of defaultdict so that
>>> accesses to undefined keys get to set to the key?
>>
>> You need to subcla
On 2014-12-01 13:05, Larry Martell wrote:
> Is there a way to set the default_factory of defaultdict so that
> accesses to undefined keys get to set to the key?
>
> i.e. if d['xxx'] were accessed and there was no key 'xxx' then
> d['xxx'] would get set to 'xxx'
>
> I know I can define a function
On Mon, Dec 1, 2014 at 1:19 PM, Ethan Furman wrote:
> On 12/01/2014 10:05 AM, Larry Martell wrote:
>>
>> Is there a way to set the default_factory of defaultdict so that
>> accesses to undefined keys get to set to the key?
>
> You need to subclass and modify __missing__ to actually pass along the
On Mon, Dec 1, 2014 at 1:19 PM, Ethan Furman wrote:
> On 12/01/2014 10:05 AM, Larry Martell wrote:
>>
>> Is there a way to set the default_factory of defaultdict so that
>> accesses to undefined keys get to set to the key?
>
> You need to subclass and modify __missing__ to actually pass along the
On 12/01/2014 10:05 AM, Larry Martell wrote:
>
> Is there a way to set the default_factory of defaultdict so that
> accesses to undefined keys get to set to the key?
You need to subclass and modify __missing__ to actually pass along the key:
--> class defaultdictkey(defaultdict):
... def __miss
On Mon, Dec 1, 2014 at 11:05 AM, Larry Martell wrote:
> Is there a way to set the default_factory of defaultdict so that
> accesses to undefined keys get to set to the key?
>
> i.e. if d['xxx'] were accessed and there was no key 'xxx' then
> d['xxx'] would get set to 'xxx'
>
> I know I can define
14 matches
Mail list logo