AeroEng43 / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

dict.setdefault is not there #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

here's what the dict method setdefault does:

def dict_setdefault(D, k, d):
    #D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
    r = D.get(k,d)
    if k not in D:
        D[k] = d
    return r

btw, here is another example for shedskin:
    http://rene.f0o.com/~rene/stuff/spacial_hash/hashmap.py

I converted the code from here so that it works with shedskin:
    http://entitycrisis.blogspot.com/2007/11/spatial-hashing.html

cheers,

Original issue reported on code.google.com by ren...@gmail.com on 12 Oct 2009 at 3:45

GoogleCodeExporter commented 8 years ago
thanks a lot for reporting! unfortunately, I'm on a (very busy) vacation at the
moment, but I will try to look into this as soon as possible..

Original comment by mark.duf...@gmail.com on 13 Oct 2009 at 2:03

GoogleCodeExporter commented 8 years ago
hey, no problem... and no rush!  I've got a work around :)    Enjoy your 
holiday.

Original comment by ren...@gmail.com on 13 Oct 2009 at 2:08

GoogleCodeExporter commented 8 years ago
btw, it looks like the problem comes from passing dict.setdefault as a method
reference, which is not supported at the moment (see the limitations section in 
the
tutorial). if you call the method directly, it should work: 

self.grid.setdefault(..)

Original comment by mark.duf...@gmail.com on 14 Oct 2009 at 3:07

GoogleCodeExporter commented 8 years ago
assuming my guess was correct.

Original comment by mark.duf...@gmail.com on 29 Oct 2009 at 1:30