« first day (1970 days earlier)      last day (1371 days later) » 

10:02 PM
Although I think I have found a bug on a response (from user Wim) on this link, but I cannot comment because I don't have enough points on whatever gamification system is going on lol, if anyone wanna have a look it might help others.
0
A: Multi-level defaultdict with variable depth?

wimYou may achieve this with a recursive defaultdict. from collections import defaultdict def tree(): def the_tree(): return defaultdict(the_tree) return the_tree() It is important to protect the default factory name, the_tree here, in a closure ("private" local function scope). ...

this will return error, unexpectedly, I believe:
d = tree()
d[1][3][1] = 5
 
10:24 PM
@PedroSpinola What kind of error? I don't get one. Please consider going forward that "an error" is never sufficient information
 
10:44 PM
My mistake, actually. Please delete what I said about Wim's code.
 
6 messages moved from Python
 

« first day (1970 days earlier)      last day (1371 days later) »