5

I have list = [] and I am adding an element to it using self.list.append('test') and I get this error - AttributeError: 'function' object has no attribute 'append'

The other list that I have defined append just fine, any ideas?

2
  • 1
    it seems that you have a function called list in your code.. Commented Jun 4, 2013 at 16:08
  • I just put the comment as an answer... Commented Jun 4, 2013 at 16:13

2 Answers 2

10

It seems you have a function in your code that is shadowing Python's built-in function named list.

Sign up to request clarification or add additional context in comments.

Comments

1

first of all,you cannot use in-built function 'list' as a variable name and second is that with function object we cannot use append

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.