Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72435

Re: Strange Behavior

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'elif': 0.05; 'attribute': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'windows': 0.15; '":"': 0.16; '#label': 0.16; 'folks,': 0.16; 'invoking': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'reproduce': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'skip:e 30': 0.24; '15,': 0.26; 'skip:_ 20': 0.27; 'header:X -Complaints-To:1': 0.27; 'skip:p 30': 0.29; "doesn't": 0.30; 'robert': 0.30; 'code': 0.31; 'file': 0.32; 'class': 0.32; '(most': 0.33; 'could': 0.34; 'anybody': 0.35; 'but': 0.35; 'thank': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'skip:_ 30': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'stated': 0.69; 'influence': 0.74; 'absolutely': 0.87
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Strange Behavior
Date Mon, 02 Jun 2014 19:59:23 +0200
Organization None
References <CANYcpZy3qZHRORFPTnvPcSV+uU2MHHPPcKuDXXuRvjNJBnKJKg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bdaffc.dip0.t-ipconnect.de
User-Agent KNode/4.11.5
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10569.1401731983.18130.python-list@python.org> (permalink)
Lines 57
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1401731983 news.xs4all.nl 2918 [2001:888:2000:d::a6]:38035
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:72435

Show key headers only | View raw


robertw89@googlemail.com wrote:

> Hello folks,
> 
> I am not sure if it is only on my system the case that the code in
> http://pastebin.com/WETvqMJN misbehaves in the stated way.
> Can anybody reproduce it?
> 
> I thought it could be that the tabs/spaces do influence it, but it doesn't
> care.
> 
> Thank you very much for your time.
> 
> Robert

I get what you expect:

$ cat bug.py
class EnumSectionContentType(object):
    DATABYTE = 2
    DATADOUBLEWORD = 3
    DATAWORD = 4
#LABEL = 0

def _getStringOfElements(elements):
    objectFileString = ""

    elements = [{'type': 2, 'data': {'elements': ['83H', '0FAH', '9AH', '27H', '81H', '49H', '0CEH', '11H']}}]

    for iterationElement in elements:
        objectFileString += "INSIDE1 "
        
        if iterationElement["type"] == EnumSectionContentType.LABEL:
            objectFileString +=  iterationElement["data"]["labelname"] + ":" + "\n"
        elif iterationElement["type"] == EnumSectionContentType.DATABYTE:
            objectFileString += "INSIDE" + "\n"

            if   iterationElement["type"] == EnumSectionContentType.DATADOUBLEWORD:
                objectFileString += objectFileString + "dd "
            elif iterationElement["type"] == EnumSectionContentType.DATABYTE:
                objectFileString += objectFileString + "db "

    return objectFileString

print(_getStringOfElements(None))
$ python3.4 bug.py
Traceback (most recent call last):
  File "bug.py", line 27, in <module>
    print(_getStringOfElements(None))
  File "bug.py", line 15, in _getStringOfElements
    if iterationElement["type"] == EnumSectionContentType.LABEL:
AttributeError: type object 'EnumSectionContentType' has no attribute 'LABEL'

Are you absolutely sure you are invoking the right bug.py?
(I think on windows you can use type instead of cat to see 
the file contents).

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Strange Behavior Peter Otten <__peter__@web.de> - 2014-06-02 19:59 +0200

csiph-web