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?

asked Oct 4, 2015 at 2:29
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.

answered Oct 4, 2015 at 2:36
2
  • 1
    Agreed. This is not a Python issue in any way. Commented Oct 4, 2015 at 2:39
  • 1
    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? Commented Oct 4, 2015 at 2:42
0

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

answered Oct 4, 2015 at 2:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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