Why can I not access this class member in python?

Posted by Peter Smit on Stack Overflow See other posts from Stack Overflow or by Peter Smit
Published on 2011-01-11T08:49:20Z Indexed on 2011/01/11 8:53 UTC
Read the original article Hit count: 200

Filed under:
|

I have the following code

class Transcription(object):
    WORD = 0
    PHONE = 1
    STATE = 2

    def __init__(self):
        self.transcriptions = []

    def align_transcription(self,model,target=Transcription.PHONE):
        pass

The important part here is that I would like to have a class member as default value for a variable. This however gives the following error:

NameError: name 'Transcription' is not defined

Why is this not possible and what is the right (pythonic) way to do something like this.

© Stack Overflow or respective owner

Related posts about python

Related posts about class-members