I have a list of objects called deckList
in my constructor. The list will hold objects of the type Deck
.
self.deckList = [Deck()]
If I get the last element in the list by,
deck = self.deckList[len(self.deckList) - 1]
Why is it that if I do, deck.
I will still get methods for a List object?
Would I not get methods for the object type Deck
?
Any tips?
asked Oct 4, 2015 at 2:29
user3325783user3325783
2 Answers 2
What methods you get depends on the auto complete, which your IDE is using. It might be broken or buggy... In any case, this has nothing to do with python.
answered Oct 4, 2015 at 2:36
-
1Agreed. This is not a Python issue in any way.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2015年10月04日 02:39:52 +00:00Commented Oct 4, 2015 at 2:39
-
1I agree. Auto complete with this code should be giving him methods for a Deck. If it isn't, it's likely a problem with the auto complete. Python can't be an easy language for doing type inference for auto complete. Or maybe Deck inherits from list, who knows?Caleb Mauer– Caleb Mauer2015年10月04日 02:42:22 +00:00Commented Oct 4, 2015 at 2:42
Indeed it is an IDE issue. Could be pyDev that I'm running on Eclipse.
answered Oct 4, 2015 at 2:43
user3325783user3325783
lang-py
list[-1]