How to extend PythonWin auto-completion - ?
tismer at tismer.com
Sun Dec 3 15:16:13 CET 2000
Jason Cunliffe wrote:
> > Use the source, Luke. I haven't checked it myself, but I guess the
> > completion is implemented in 100% pure Python, so it should not be too
> > hard to find the place where it's done, and improve it. Don't forget
> > to send your patches to Mark Hammond afterwards.
> ok I will try...
> Q1: Does anyone know where the detection source code which determsni what
> happens when you type "." after some text in PythonWin shell?
Actually I know.
But here is a little trick for you how to find out yourself:
When you are typing the dot in thing.stuff for instance,
there is an attribute lookup taking place right after you
were hitting the dot.
Now, how do we find out where this code lives?
Easy! Write a little class with a ridiculous __getattr__
and save the calling frame chain. Here it is:
>>> class gotcha:
... def __getattr__(self, name):
... global bingo
... import sys
... ign, ign, bingo = sys.exc_info()
>>> catchit = gotcha()
>>> catchit. # hit escape here
<traceback object at 00D64E30>
Now type ctrl-b and browse the traceback object. It has a frame
which is you interactive window. Open it's f_back frame, open
its f_code object, and you can read the filename:
f_lineno tells you to go to line 413. You are exactly after
the code that tried to find properties of your object.
Neat, isn't it?
But be warned, tricky stuff here :-)
ciao - chris
Christian Tismer :^) <mailto:tismer at tismer.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net
14163 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
where do you want to jump today? http://www.stackless.com
More information about the Python-list