use of __new__ to permit "dynamic" completion within (any?) IDE ?

Jean-Michel Pichavant jeanmichel at sequans.com
Wed Dec 8 09:51:10 EST 2010


gst wrote:
> greg.
>
> nb: so this "hack" is only relevant during dev ; once the project
> would be finished the "hack" could be removed (i.e : in class2 init I
> would directly do : self.object1 = object1)
>   

Expect some bugs then on the 'release' version.
I'm not sure I understood everything you mentioned in your OP, however 
writing python code on class creation to make Eclipse completion 'work' 
is ... a very bad idea IMO.
Just don't do it.

quoting eclipse page:

"Pydev [...] uses advanced type inference techniques to provide features 
such code completion and code analysis"

I don't know exactly what's hidden behind this marketing stuff. Did you 
try to document your method with a markup language supported by Eclipse 
(if there is any)?

class class2(object):
    def __init__(self, object1, *args, **kwargs):
    """blablabla

    @param object1: a L{class1} reference
    """
    self.object1 = object1

The docstring would be the only way for an IDE to infer a argument type.
Note that I used the epydoc markup language because it's the only one I 
know but it's unlikely supported by Eclipse. You better try 
reStructuredText.

JM



More information about the Python-list mailing list