Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Music Scale Generator
-
Hi,
Getting an error that “mode object has no attribute scale_steps” when I run this, but I think everything is ok. Does anyone see where there is a disconnect??legal_mode = [ "Ionian", "Dorian", "Phrygian", "Lydian", "Mixolydian", "Aeolian", "Locrian"] stepping = [2, 2, 1, 2, 2, 2, 1] major_mode = ["Ionian"] class Mode(): def __init__(self,title): self.title = title self.ismajor = title in major_mode tonic = legal_mode.index(title) self.stepping = stepping[tonic:]+stepping[:tonic] def __str__(self): return "Title: {}, Major{}".format(self.title, self.ismajor) def scale_steps(self): return "Half-steps{}".format(''.join(str(c) for c in self.stepping)) mode1 = Mode("Ionian") print(mode1) print(mode1.scale_steps()) mode2 = Mode("Dorian") print(mode2) print(mode2.scale_steps())```
-
@craigmrock Shift left the two def str and scale_steps, they are inside init
legal_mode = [ "Ionian", "Dorian", "Phrygian", "Lydian", "Mixolydian", "Aeolian", "Locrian"] stepping = [2, 2, 1, 2, 2, 2, 1] major_mode = ["Ionian"] class Mode(): def __init__(self,title): self.title = title self.ismajor = title in major_mode tonic = legal_mode.index(title) self.stepping = stepping[tonic:]+stepping[:tonic] def __str__(self): return "Title: {}, Major{}".format(self.title, self.ismajor) def scale_steps(self): return "Half-steps{}".format(''.join(str(c) for c in self.stepping)) mode1 = Mode("Ionian") print(mode1) print(mode1.scale_steps()) mode2 = Mode("Dorian") print(mode2) print(mode2.scale_steps())