omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Random music scale generator

    Pythonista
    pythonista
    2
    3
    2819
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • craigmrock
      craigmrock last edited by ccc

      Looking to create a database that retrieves scales for guitar practice. At the moment, I just want it to list a major or minor scale when you answer the question: “Major or minor scale?”
      I’m a noob, trying to take some class examples and make them into what I’d like to work on.

      import random
      
      class scale:
      	def __init__(self,minor=False, major=True, **kwargs):
      		for key,value in kwargs.items():
      			setattr(self,key,value)
      		
      class Ionian(scale):
      	def __init__(self):
      		data = {
      			"value": 'major'
      		}
      		super().__init__(**data)
      		
      class Dorian(scale):
      	def __init__(self):
      		data = {
      			"value": 'minor'
      		}
      		super().__init__(**data)
      		
      class Phrygian(scale):
      	def __init__(self):
      		data = {
      			"value": 'minor'
      		}
      		super().__init__(**data)
      			
      class Lydian(scale):
      	def __init__(self):
      		data = {
      			"value": 'major'
      		}
      		super().__init__(**data)
      			
      class Mixolydian(scale):
      	def __init__(self):
      		data = {
      			"value": 'major'
      		}
      		super().__init__(**data)
      			
      class Aeolian(scale):
      	def __init__(self):
      		data = {
      			"value":'minor'
      		}
      		super().__init__(**data)
      		
      class Locrian(scale):
      	def __init__(self):
      		data = {
      			"value": 'minor'
      		}
      		super().__init__(**data)
      		
      scales = [Ionian(), Dorian(), Phrygian(), Lydian(), Mixolydian(), Aeolian(), Locrian()]
      
      for scale in scales:
      	arguments = [scale,scale.value]
      	string = "{}: - value:{}".format(*arguments)
      
      while True:
      	choice = input("Major or Minor scale?: ").strip().title()
      	
      	if choice in scale:
      		mode = int(input("Do you like a particular mode?").strip())
      
      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by ccc

        The second last line is a problem... Two solutions to try...

        1. Change scale to scales (plural).
        2. Change scale to ('Major', 'Minor') .

        I think the second is what you really intended.

        craigmrock 1 Reply Last reply Reply Quote 1
        • craigmrock
          craigmrock @ccc last edited by

          @ccc thanks, that cleared up one of the errors I was getting through experimenting.
          Craig

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors