0

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?

2
  • 2
    You haven't posted enough code for us to be able to answer that question. Maybe post a bit of context? Commented Oct 4, 2015 at 2:35
  • The pythonic way to get the last element of a list is list[-1] Commented Oct 4, 2015 at 2:42

2 Answers 2

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.

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

2 Comments

Agreed. This is not a Python issue in any way.
I 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?
0

Indeed it is an IDE issue. Could be pyDev that I'm running on Eclipse.

Comments

Your Answer

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