Deprecating reload() ???
Hung Jung Lu
hungjunglu at yahoo.com
Mon Mar 15 19:15:00 EST 2004
David MacQuigg <dmq at gain.com> wrote in message news:<fc0c50htlip4mtpjjdhbuenn6m38o3mi9u at 4ax.com>...
> On Mon, 15 Mar 2004 11:33:04 -0600, Jeff Epler <jepler at unpythonic.net>
> wrote:
>
> >The only problem I can see with reload() is that it doesn't do what you
> >want. But on the other hand, what reload() does is perfectly well
> >defined, and at least the avenues I've seen explored for "enhancing" it
> >look, well, like train wreck.
>
> It's worse than just a misunderstanding. It's a serious limitation on
> what we can do with editing a running program.
As I said in another message, you CAN do the kinds of things you want
to do (edit-and-continue), if you use weakrefs, and use classes
instead of modules. Take a look at the weakref module. I am not saying
that it's trivial in Python: it does require a bit of work, but
edit-and-continue in Python is definitely doable. I've done it, many
other people have done it.
(Of course, if you asked whether the Ruby behavior is better, I'd
think so. I think it's better to automatically replace class behavior
on reload, by default, and leave open the possibility of explicitly
refusing replacement. Python is the opposite: by default the class
behavior does NOT get modified, and you have to do somework to replace
it.)
I think it is an historical accident in Python that modules are not
made more class-like. Another thing I have seen people wishing having
is getter/setter accessor methods (or properties) for module-level
attributes.
It usually is a better practice in Python to store attributes in
classes rather than modules, exactly because down the future you'd
often start to wish having class-like behaviors for your modules.
regards,
Hung Jung
More information about the Python-list
mailing list