|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /proc/self/root/usr/lib/python2.4/site-packages/mx/Stack/ |
Upload File : |
import string
class UserStack:
def __init__(self):
self.stack = ()
def push(self,x):
self.stack = (x,self.stack)
def pop(self):
x, self.stack = self.stack
return x
def not_empty(self):
return len(self.stack) != 0
def top(self):
return self.stack[0]
def __len__(self):
i = 0
s = self.stack
while len(s) != 0:
s = s[1]
i = i + 1
return i
def __repr__(self):
l = []
s = self.stack
while len(s) != 0:
l.append(repr(s[0]))
s = s[1]
return '<UserStack [%s]>' % string.join(l,', ')
def __str__(self):
l = []
s = self.stack
while len(s) != 0:
l.append(s[0])
s = s[1]
return 's' + repr(l)