I was thinking that it would be nice to allow user script packages/functions to be added to auto complete. Is this something that would have to be a custom module? I also wonder if you could write a script that could loop through a script package/file and return all of the contained function definitions and parameters?
It would be nice
We’re actively working on improvements to the script editor. Autocomplete for user functions won’t make the first round of improvements, but is definitely on the list to add.
It wouldn’t really be possible through a custom module; you wouldn’t have any good place to hook in to deliver autocompletion even if you had it.
This isn’t too shabby for quick and dirty module inspection
def testFunc1(a): x=1 def testFunc2(a,b): x=1 def testFunc3(a,b,c): x=1 def testFunc4(a,b,c,d): x=1
code = test.getCode() defs = code.split('def') for definition in defs: print definition.split(':')
testFunc1(a) testFunc2(a,b) testFunc3(a,b,c) testFunc4(a,b,c,d)
Blegh. What happens when the three letters “def” show up elsewhere? Instead, use
dir() to give you all the symbols,
getattr() to extract the objects, and
callable() to distinguish code from variables.
Yea I suppose this sort of thing would break it
def coolMaths(): # definitely change this later x = 1 / 0
If possible I think it would be very helpful if too that you autocomplete of user functions could grab the doc string of the function and display it the way the built-in’s work
def myFunct(a, b): """ Show the stuff in here Args: a: int, description b: string, description Returns: someReturnVal """ pass
I’m ignoring classes, methods, and the kwarg stuff for now…
from inspect import isfunction, getargspec modObj = project.test syms = dir(modObj) for sym in syms: attr = getattr(modObj, sym) if isfunction(attr): print "%s(%s)" % (sym, ','.join(getargspec(attr)))