Help and optimization hints, anyone?
Kim Petersen
kim at lignus.dk
Fri Jan 23 09:48:49 EST 2004
More information about the Python-list mailing list
Fri Jan 23 09:48:49 EST 2004
- Previous message (by thread): Help and optimization hints, anyone?
- Next message (by thread): Help and optimization hints, anyone?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Den Fri, 23 Jan 2004 12:32:04 +0000. skrev John J. Lee: > Kim Petersen <kim at lignus.dk> writes: > >> I've worked on this table object a bit too long - and seem to have >> stared too long at the code. Can someone see where it goes wrong in >> the insertrow function? > > I made a few comments before I realised it was a Tkinter question, so > no answer, sorry! Just some style hints. thx. no problem tho - i should've remembered. >> >> class UserDict: > > Bad name -- UserDict is a standard library module. In 2.2 or newer, > you can subclass dict. In 2.3, you also have the option of > subclassing UserDict.DictMixin. If you just want to implement part of > the maping interface, just call your class something other than > UserDict -- say SimpleDefaultDictBase. > Actually i was planning to use the standard UserDict (basically because a class is hashable and dict isn't) - i got carried away and put some default handling in it as well - but didn't rename ;-) > > dict is also a bad name -- this is the name of the builtin dictionary > type, which you've just clobbered (in the local scope). Hmmm - isn't it called __dict__ ? >> >> def haskey(self,name): return self.dict.has_key(name) > > Did you really mean to call it that? The dict interface has a method > .has_key(), not .haskey(). yup - oversight > > >> class Cell(UserDict): >> defaults={"width": 0,"height": 0,"text": '',"color": "black","background": "white", >> "widgets": None} > [...] > > Haven't read much further, but it looks like you might be better off > using attribute access rather than indexing. In 2.2, use properties. > Earlier, use __setattr__ / __getattr__ (make sure you read the docs). this migrated from a regular dict which i had to drop because its not hashable as mentioned earlier - next step __(get|set)attr__. > > > John -- Privat ========================== Kim Petersen ==================== Arbejde Email kim at vindinggaard.dk ===== Jens Grøns Vej 11 ===== Email kim at lignus.dk Tlf +45 75 83 15 50 ============== 7100 Vejle ========= Tlf +45 75 83 15 51 Fax +45 75 83 15 62 ============= DK - Danmark ======== Fax +45 75 83 15 62
- Previous message (by thread): Help and optimization hints, anyone?
- Next message (by thread): Help and optimization hints, anyone?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list