Magic Module Methods?
Magnus Lie Hetland
mlh at idi.ntnu.no
Sat Oct 20 19:36:54 EDT 2001
More information about the Python-list mailing list
Sat Oct 20 19:36:54 EDT 2001
- Previous message (by thread): Magic Module Methods?
- Next message (by thread): Magic Module Methods?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Tim Peters" <tim.one at home.com> wrote in message news:mailman.1003614080.13207.python-list at python.org... > [Magnus Lie Hetland] > > I just found myself needing (or wanting) a module which > > could have default values for variables that weren't set; > > I expect it would be near-infinitely clearer if you simply set the module > variables to their default values explicitly at module initialization time. OK - bad example (and terse explanation). The situation was this: I was using a module as a config file, and at the same time as an object containing defaults at some other point in the program (available for users of the library). Therefore, the defaults should be accessible from the module, but the people writing the config file might not want to set absolutely all the values... I could of course do an update() on the module __dict__, and that might be clearer, but possibly not near-infinitely? ;) [snip] > Probably, with enough code to implement it. Lists could act more like > integers too, but I doubt I'd fight for that either <wink>. Well, I wasn't saying that modules should act like lists or integers or any other specific class of objects -- simply like objects in general. (Everything is supposed to be an object now, right?) > you-can-subclass-the-module-type-in-2.2-but-hoping-you-don't-ly > y'rs - tim Subclassing the module type wouldn't be of much help here, would it? I'd still end up with the standard object-as-module trick, only using a module object. I still couldn't get the object-like behaviour directly from the module. (And no, I probably won't subclass it anyway.) I don't really see what's wrong with the idea (of magic functions in a module), but I'll accept "Tim doesn't like it" as a valid reason. :) -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick
- Previous message (by thread): Magic Module Methods?
- Next message (by thread): Magic Module Methods?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list