Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -4,11 +4,11 @@ · 3 unmodified lines | ||
| 4 | 4 | import sys |
| 5 | 5 | py3 = sys.version_info[0] == 3 |
| 6 | 6 | if py3: |
| 7 | − str_instances = [str] | |
| 8 | − int_instances = [int] | |
| 7 | + str_instances = str | |
| 8 | + int_instances = int | |
| 9 | 9 | else: |
| 10 | − str_instances = [str, unicode] | |
| 11 | − int_instances = [int, long] | |
| 10 | + str_instances = (str, unicode) | |
| 11 | + int_instances = (int, long) | |
| 12 | 12 | |
| 13 | 13 | def note2midi(note): |
| 14 | 14 | " convert note name to midi note number, e.g. [C-1, G9] -> [0, 127] " |
| @@ -16,7 +16,7 @@ def note2midi(note): · 1 unmodified line | ||
| 16 | 16 | _valid_modifiers = {None: 0, u'♮': 0, '#': +1, u'♯': +1, u'\udd2a': +2, |
| 17 | 17 | 'b': -1, u'♭': -1, u'\ufffd': -2} |
| 18 | 18 | _valid_octaves = range(-1, 10) |
| 19 | − if isinstance(note, str_instances): | |
| 19 | + if not isinstance(note, str_instances): | |
| 20 | 20 | raise TypeError("a string is required, got %s (%s)" % (note, str(type(note)))) |
| 21 | 21 | if len(note) not in range(2, 5): |
| 22 | 22 | raise ValueError("string of 2 to 4 characters expected, got %d (%s)" \ |
| @@ -51,7 +51,7 @@ def note2midi(note): · 28 unmodified lines | ||
| 51 | 51 | |
| 52 | 52 | def midi2note(midi): |
| 53 | 53 | " convert midi note number to note name, e.g. [0, 127] -> [C-1, G9] " |
| 54 | − if isinstance(midi, int_instances): | |
| 54 | + if not isinstance(midi, int_instances): | |
| 55 | 55 | raise TypeError("an integer is required, got %s" % midi) |
| 56 | 56 | if midi not in range(0, 128): |
| 57 | 57 | raise ValueError("an integer between 0 and 127 is excepted, got %d" % midi) |