Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting scale results in a list or another data type #81

Open
ChapelHeel66 opened this issue Aug 13, 2021 · 1 comment
Open

Getting scale results in a list or another data type #81

ChapelHeel66 opened this issue Aug 13, 2021 · 1 comment

Comments

@ChapelHeel66
Copy link

ChapelHeel66 commented Aug 13, 2021

Is there a way to return scales as lists or tuples? In Python 3.7 only returns an object, like this:

scales.Ionian('C')
<Scale object ('C ionian')>

You can print it, like so:

print(scales.Ionian('C'))
Ascending: C D E F G A B C
Descending: C B A G F E D C

Here are the scales object attributes, none of which produces the actual notes, except the str, which I guess I could perform some operations on to extract the individual notes.

dir(scales.Ionian('C'))
['class', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'len', 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'weakref', 'ascending', 'degree', 'descending', 'name', 'octaves', 'tonic', 'type']

@edudobay
Copy link
Collaborator

edudobay commented Sep 7, 2021

HI @ChapelHeel66! If you want the result as a list, then you can check the ascending() or descending() methods. They are also used in the __str__ implementation that you commented about some kind of reverse engineering.

Maybe we could change the __repr__ method so it returns more information — something like

<Scale object ('C ionian') [C, D, E, F, G, A, B, C]>

Do you feel like this could be useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants