Global dictionary or class variables

Mr.SpOOn mr.spoon21 at gmail.com
Fri Oct 24 16:44:38 EDT 2008


Hi,
in an application I have to use some variables with fixed valuse.

For example, I'm working with musical notes, so I have a global
dictionary like this:

natural_notes = {'C': 0, 'D': 2, 'E': 4 ....}

This actually works fine. I was just thinking if it wasn't better to
use class variables.

Since I have a class Note, I could write:

class Note:
    C = 0
    D = 2
    ...

Which style maybe better? Are both bad practices?



More information about the Python-list mailing list