Considering this, I would say it's just plain unpythonic to implement a stack structure; instead, just use a list
, that really is a dequeue and thus can be used as both a stack and a queue.
On the other hand, the inheritance I suggested happens to violate Liskov's subsitutionsubstitution principle.
Although there's no problem with adding push
and peek
methods with respect to this principle, my implementation changes the signature of the pop
method, which is not allowed by this principle.
On the Liskov substitution principle: