[Tutor] Question regarding lists and manipulating items in lists.

Andreas Perstinger andipersti at gmail.com
Wed Jan 16 07:20:15 CET 2013


On 16.01.2013 01:23, Scurvy Scott wrote:
 > After playing with your example I keep being told that list has no
 > attribute int_to_note. I know what the problem is, I just don't know
 > how to fix it.
[SNIP]
 > So right now my code is:
 >
 > import mingus.core.notes as notes
                               ^^^^^
On this line you import your module and give it the name "notes".

 > def make_notes(num_notes):
 > 	it = fib()
 > 	notes = []
         ^^^^^

Inside your function "notes" is a list.

 > 	for i in range(num_notes):
 > 		n = next(it) % 12
 > 		notes.append(notes.int_to_note(n))
                              ^^^^^

Since "notes" is a list inside the function, Python tries to find the 
method "int_to_note" for a list and fails. But I think you want to use 
the function which is defined in your module.

You have to either rename your module reference or your list.

Bye, Andreas


More information about the Tutor mailing list