On 8 déc, 15:51, Jean-Michel Pichavant <jeanmic...@sequans.com> wrote:
Hi, > gst wrote: > > 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. even with the "assert(self is _self)" in the "if _self:" condition in the new and/or init methods of the class1 ? > 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. yes I'm trying to find better ways for having completion works out of the box in this case.. (that would be a high help to my opinion). > 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)? pydev completion apparently is restricted (as far as i see) to some very specific cases (basically it works when you import a module at top of another one and that you instantiate objects from the imported module within the init methods of the classes of the module which is importing the other one (but so "circular" references created on some objects from the first module (the one imported) in the second one won't have the completion working for them (that's what I see)). > 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 well, I'm not very used to docstrings in fact but it's effectively a way to achieve this ; well certainly better than doing this kind of "ugly" hack so. I'll have a try at that. Thanks for your reply, regards, greg. -- http://mail.python.org/mailman/listinfo/python-list