Prev: What timeouts are required when reading SSL certificates withPython 2.6.4?
Next: expat parsing error
From: Leo Breebaart on 1 Jun 2010 07:48 When fed the following code: def Foo(): class A(object): def __init__(self): pass class B(object): def __init__(self): pass PyChecker 0.8.18 warns: foo.py:9: Redefining attribute (__init__) original line (5) I do not understand what is meant by this warning. In fact, it simply seems wrong -- but I have learned not to jump to that conclusion too quickly, so I was hoping someone here could perhaps enlighten me... Many thanks in advance, -- Leo Breebaart <leo(a)lspace.org>
From: Peter Otten on 1 Jun 2010 08:23 Leo Breebaart wrote: > > When fed the following code: > > def Foo(): > > class A(object): > def __init__(self): > pass > > class B(object): > def __init__(self): > pass > > PyChecker 0.8.18 warns: > > foo.py:9: Redefining attribute (__init__) original line (5) > > I do not understand what is meant by this warning. In fact, it > simply seems wrong -- but I have learned not to jump to that > conclusion too quickly, so I was hoping someone here could > perhaps enlighten me... You are right, that's a false positive. pychecker seems to confuse the namespaces. Peter
From: Steven W. Orr on 1 Jun 2010 10:27 On 6/1/2010 7:53 AM, Xavier Ho wrote: > On 1 June 2010 21:48, Leo Breebaart <leo(a)lspace.org > <mailto:leo(a)lspace.org>> wrote: > > > When fed the following code: > > def Foo(): > > class A(object): > def __init__(self): > pass > > class B(object): > def __init__(self): > pass > > PyChecker 0.8.18 warns: > > foo.py:9: Redefining attribute (__init__) original line (5) > > > Out of curiosity, why are you defining two classes inside a function? > > -Xav > In terms of constructing a minimal example, Foo might be fodder for a closure that either returns A or B. Just s stab in the dark... -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net
From: Leo Breebaart on 1 Jun 2010 11:25 On 6/1/2010 7:53 AM, Xavier Ho wrote: > > Out of curiosity, why are you defining two classes inside a > > function? Not my code! Not my code! :-) This code was contributed by someone else, and I merely took my default action (in such cases) of running pyflakes, pychecker, and pylint on it before doing anything else, just to see what comes up. As far as I can tell the sole reason for that code being structured the way it is, is to provide a kind of module-within-a-module and not clutter up the outer module with these helper classes needed only by the foo() function. -- Leo Breebaart <leo(a)lspace.org>
From: Terry Reedy on 1 Jun 2010 11:38 On 6/1/2010 8:23 AM, Peter Otten wrote: > Leo Breebaart wrote: > >> >> When fed the following code: >> >> def Foo(): >> >> class A(object): >> def __init__(self): >> pass >> >> class B(object): >> def __init__(self): >> pass >> >> PyChecker 0.8.18 warns: >> >> foo.py:9: Redefining attribute (__init__) original line (5) >> >> I do not understand what is meant by this warning. In fact, it >> simply seems wrong -- but I have learned not to jump to that >> conclusion too quickly, so I was hoping someone here could >> perhaps enlighten me... > > You are right, that's a false positive. pychecker seems to confuse the > namespaces. Consider sending this example back to the pychecker author. The program does not seem to be interpreting the nested class statements properly.
|
Next
|
Last
Pages: 1 2 Prev: What timeouts are required when reading SSL certificates withPython 2.6.4? Next: expat parsing error |