FAQ
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 at lspace.org>

Search Discussions

  • Xavier Ho at Jun 1, 2010 at 11:53 am

    On 1 June 2010 21:48, 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)
    Out of curiosity, why are you defining two classes inside a function?

    -Xav
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20100601/952c18cd/attachment.html>
  • Steven W. Orr at Jun 1, 2010 at 2:27 pm

    On 6/1/2010 7:53 AM, Xavier Ho wrote:
    On 1 June 2010 21:48, Leo Breebaart <leo at 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
  • Leo Breebaart at Jun 1, 2010 at 3:25 pm

    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 at lspace.org>
  • Peter Otten at Jun 1, 2010 at 12:23 pm

    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
  • Terry Reedy at Jun 1, 2010 at 3:38 pm

    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.
  • MrJean1 at Jun 1, 2010 at 6:08 pm
    Although PyChecker 0.8.18 is quite an improvement over previous
    releases, it does have quirks. The PyChecker postprocessor might be
    helpful, see

    <http://code.activestate.com/recipes/546532/>

    /Jean

    On Jun 1, 4:48?am, 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...

    Many thanks in advance,

    --
    Leo Breebaart ?<l... at lspace.org>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 1, '10 at 11:48a
activeJun 1, '10 at 6:08p
posts7
users6
websitepython.org

People

Translate

site design / logo © 2022 Grokbase