Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does eclipse's pydev do code completion?
    primarykey
    data
    text
    <p>Does anyone know how pydev determines what to use for code completion? I'm trying to define a set of classes specifically to enable code completion. I've tried using <code>__new__</code> to set <code>__dict__</code> and also <code>__slots__</code>, but neither seems to get listed in pydev autocomplete. </p> <p>I've got a set of enums I want to list in autocomplete, but I'd like to set them in a generator, not hardcode them all for each class.</p> <p>So rather than</p> <pre><code>class TypeA(object): ValOk = 1 ValSomethingSpecificToThisClassWentWrong = 4 def __call__(self): return 42 </code></pre> <p>I'd like do something like</p> <pre><code>def TYPE_GEN(name, val, enums={}): def call(self): return val dct = {} dct["__call__"] = call dct['__slots__'] = enums.keys() for k, v in enums.items(): dct[k] = v return type(name, (), dct) TypeA = TYPE_GEN("TypeA",42,{"ValOk":1,"ValSomethingSpecificToThisClassWentWrong":4}) </code></pre> <p>What can I do to help the processing out?</p> <p><strong>edit:</strong> The comments seem to be about questioning what I am doing. Again, a big part of what I'm after is code completion. I'm using python binding to a protocol to talk to various microcontrollers. Each parameter I can change (there are hundreds) has a name conceptually, but over the protocol I need to use its ID, which is effectively random. Many of the parameters accept values that are conceptually named, but are again represented by integers. Thus the enum. </p> <p>I'm trying to autogenerate a python module for the library, so the group can specify what they want to change using the names instead of the error prone numbers. The <code>__call__</code> property will return the id of the parameter, the enums are the allowable values for the parameter. </p> <p>Yes, I can generate the verbose version of each class. One line for each type seemed clearer to me, since the point is autocomplete, not viewing these classes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload