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


Groups > comp.lang.python > #72435

Re: Strange Behavior

From Peter Otten <__peter__@web.de>
Subject Re: Strange Behavior
Date 2014-06-02 19:59 +0200
Organization None
References <CANYcpZy3qZHRORFPTnvPcSV+uU2MHHPPcKuDXXuRvjNJBnKJKg@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.10569.1401731983.18130.python-list@python.org> (permalink)

Show all headers | 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