Friday, 16 August 2013

Tip to improve autocomplete unknow variables in python with pydev

See this article first.

Python use dynamic type, so IDE can unknow variable in some cases like if you want autocomplete string type:
a.
Ctrl+space and pydev don't show any thing.

I know some ways to solve:

Using assert and isinstance

import string

def fun1(a):
    a = string(a)
    a.

fun1("hello")

Cast the object/variable back to its type


import string

def fun1(a):
    a = string(a)
    a.

fun1("hello")




New on PyDev 2.8.0
http://pydev.org/manual_adv_type_hints.html

Example:
import string

def fun1(a):
    '@type a: string'
    a.

fun1("hello")



or you can autocomple If write two charactor, this will autocomplete in all classes

No comments:

Post a Comment