[Tutor] redirecting help -- is this a bad idea?
Brian van den Broek
bvande at po-box.mcgill.ca
Sun Aug 1 01:36:27 CEST 2004
Kent Johnson said unto the world upon 31/07/2004 19:03:
> You are right on both counts.
> Assigning pyhelp = help makes both variables point to the same object
> (the original instance of _Helper). If you then rebind help to a
> different object, the binding to pyhelp persists.
> The way to think about assignment in Python is that the variable is just
> a reference to the actual value. Python variables are just names for
> values. Values have their own existence. An assignment statement binds a
> variable to a value. "pyhelp = help" means, "Whatever value help is
> bound to, bind pyhelp to the same thing."
> (I hope I haven't confused you too much, I don't think I'm explaining
> this very well.)
> I missed the point that your _PyHelper class has a different __repr__()
> than the standard one. You do need a new class if you want to change the
> behavior of the built-in help.
thanks for clarifying. Easy enough to have missed the __repr__ change.
Past that, there was nothing unclear in what you said. The thing that
threw me is that I'm just starting on trying to apply the OOP features of
Python. While I believe I understand the ideas in the abstract just fine,
the application part is a horse of an entirely different colour ;-) (It's
even got me feeling less certain about aspects of Python I thought I had
Anyway, thanks again and best,
> At 06:15 PM 7/31/2004 -0400, Brian van den Broek wrote:
>>> - If you continue down the path you show below, there is no need to
>>> define _PyHelper. You can just assign
>>> pyhelp = help
>>> Then define your own helper and assign it to help.
>> OK, let me run that back to see if I follow the intent: Before I make
>> my own help, the standard one is present as always. Then
>> pyhelp = help
>> assigns pyhelp to that standard help function, and that assignment
>> persists even after I have done my thing to make help call my custom
>> If I've got that right, then won't there be the small problem that
>> typing pyhelp at the prompt will give the old instructions of help?
>> (As in, it will still say "help(object) for help about object", etc.)
>> But that won't work as expected, once I've redirected help. I'd
>> thought I needed to use the class PyHelper just so that pyhelp would
>> print out the new, customized way to get to the pydoc functionality.
More information about the Tutor