Codecompletion for classes and external files
I just bought Pythonista, and was wondering why there are no code completion suggestions for classes declared.
If i declare a variable to be equal to one of my classes, the variable gets no code completion for the functions of that class.
(same for imported other scripts)
Is that something which could be done in the near future? Or is that asking too much from a iPad IDE?
Or maybe i am doing something wrong....
Providing good code completion for methods and attributes of custom objects in a dynamic language like Python is actually pretty difficult. Variables have no declared type in Python, so the editor can't really know of which type your variable is.
It's possible to make some educated guesses for common cases (like assigning the result of a constructor), but mostly the type of an object returned from a function depends on a lot of factors that aren't known until runtime. Even if your function/method always returns the same type, it would require significant effort (static analysis) to find out what type that is without running the code (which might have side effects that are definitely not desirable when doing code completion).
Maybe allow users to specify return types in docstrings and parse those? Like this:
Gives the current position of the ball.
That way, the difficulty of parsing a dynamically typed language is lessened, and users can still benefit from the added code completion feature. If they dont specify the @returns thing, then there will just be no code completion for it.