Re: UserDict deprecated
Hello, Alex Martelli wrote: The DictMixin class from the UserDict module is *not* deprecated -- only the UserDict class from the same module. (If you found info saying otherwise pls provide a URL: the info is wrong and I'll try to get it fixed -- thanks!). DictMixin's purpose is exactly as you state: letting you make a complete mapping class out of one which only supplies the very basics, by mix-in inheritance. If UserDict is deprecated why is it still used in the os module ? (in python V. 2.4) The std lib should be a good example for python coding, if something is deprecated it should not be used in the std lib. Some weeks ago I had ten minutes of spare time and rewrote the 'os' module to use dict and there was no problem with it. But due to lack of time I was not able to run tests and submitted no patch. I will try this next week. bye by Wolfgang -- http://mail.python.org/mailman/listinfo/python-list
Re: UserDict deprecated
Uwe Mayer wrote: Why is the UserDict module is deprecated after Python 2.2. The application of it I have in mind is, i.e. multiple inheritance from file and dic - which is not possible. I am curious, what would you do with a class that derives from both file and dict? -- Hans Nowak http://zephyrfalcon.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: UserDict deprecated
Uwe Mayer wrote: Why is the UserDict module is deprecated after Python 2.2. The application of it I have in mind is, i.e. multiple inheritance from file and dic - which is not possible. [...] I was writing a class that read /writes some binary file format. I implemented the functions from the file interface such that they are refering to records. However, the file format has some header fields and I'd wanted to grant access to those via the dict-interface. Another example: working with PyQt I have an instance of a QListView and wanted to use the list-interface to get and set individual records. If it's just a matter of attribute access, implementing the relevant __getitem__ and __setitem__ methods will probably suffice. I don't think that deriving from dict or list will do you much good here... most of the methods will be irrelevant, or won't do what you want, so you have to override them anyway. -- Hans Nowak http://zephyrfalcon.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: UserDict deprecated
Uwe Mayer wrote: Saturday 01 January 2005 22:48 pm Hans Nowak wrote: I am curious, what would you do with a class that derives from both file and dict? I was writing a class that read /writes some binary file format. I implemented the functions from the file interface such that they are refering to records. However, the file format has some header fields and I'd wanted to grant access to those via the dict-interface. If you implemented the file interface functions yourself, why do you want to inherit from file? Another example: working with PyQt I have an instance of a QListView and wanted to use the list-interface to get and set individual records. But just inheriting from list won't make this work, will it? Don't you want to do something like: class C(QListView): def __getitem__(self, i): return self.getIndividualRecord(i) # or whatever method gives # you the record Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: UserDict deprecated
Uwe Mayer [EMAIL PROTECTED] wrote: ... If I used UserDict I would not need to specify all methods UserDict provides alreay, anyway. The DictMixin class from the UserDict module is *not* deprecated -- only the UserDict class from the same module. (If you found info saying otherwise pls provide a URL: the info is wrong and I'll try to get it fixed -- thanks!). DictMixin's purpose is exactly as you state: letting you make a complete mapping class out of one which only supplies the very basics, by mix-in inheritance. Alex -- http://mail.python.org/mailman/listinfo/python-list