alan.gauld at freenet.co.uk
Mon Aug 21 17:33:29 CEST 2006
> I'm a newbie to Python. I wanted to write a graphical interface
> which would show the built-in documentation (I mean dir() and
> __doc__ ) of Python. The code shows how far I got before realizing
> that I had to use some self-modification feature (converting a
> string to a function or to an object; i'm not sure you would call it
> self-modification in an interpreted language).
Usually this (string to function/object) is best done in Python
by either using a dictionary or the getattr/setattr methods.
> I was googling around, and searching in the maillist archives and
> found this:
> Unanswered for two years. Not too promising :)
It wasn't answered because its a bit too open ended.
It asks for someone to give a "tutorial" on self modification
aimed at other language users... Thats a pretty broad brief.
> P.S.: I'm new to this mailing list, so I don't know whether it is
> allowed to send code as attachment. (I didn't found anything about
> your policy in the subscription site. ) If not, I'm sorry.
Short code snippets (<100 lines?) are OK, longer than
that and we prefer a URL link.
Can you give us some more specific examples of what you
are trying to do that requires "self modification"? For a help
browser I'd expect getattr to be sufficient in most cases.
Author of the Learn to Program web site
More information about the Tutor