default behavior
wheres pythonmonks
wherespythonmonks at gmail.com
Fri Jul 30 07:59:52 EDT 2010
Instead of defaultdict for hash of lists, I have seen something like:
m={}; m.setdefault('key', []).append(1)
Would this be preferred in some circumstances?
Also, is there a way to upcast a defaultdict into a dict? I have also
heard some people use exceptions on dictionaries to catch key
existence, so passing in a defaultdict (I guess) could be hazardous to
health. Is this true?
W
On Fri, Jul 30, 2010 at 6:56 AM, Duncan Booth
<duncan.booth at invalid.invalid> wrote:
> Peter Otten <__peter__ at web.de> wrote:
>> real is a property, not a method. conjugate() was the first one that
>> worked that was not __special__. I think it has the added benefit that
>> it's likely to confuse the reader...
>>
> Ah, silly me, I should have realised that.
>
> Yes, micro-optimisations that are also micro-obfuscations are always the
> best. :^)
>
> --
> Duncan Booth http://kupuguy.blogspot.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list