Python beginner having trouble running code
Posted
by Protean
on Stack Overflow
See other posts from Stack Overflow
or by Protean
Published on 2010-03-15T04:33:24Z
Indexed on
2010/03/15
4:49 UTC
Read the original article
Hit count: 487
For some reason this code will not seem to run in the interpreter. When I hit F5 nothing happens, not even the debugger seems to recognize it. I assume it has something to do with the class, as when removed the interpreter seems to recognize the rest of the code. Please tell me what I am doing wrong. Edit: I have restarted the interpreter multiple times, any other piece of code I try to load runs fine, just this one is having trouble.
print ('Why won't this work?')
class sorting_class:
def __init__(self):
self.order = ['a', 'b', 'c', 'd']
self.globali = 0
self.orderi = 0
self.sortedlist = []
def sort(self, array):
carry, leave = []
for arrayi in array:
print ('run', arrayi)
if self.order[self.orderi] == arrayi[self.globali]:
carry.append(arrayi)
else:
if self.globali != 0:
leave.append(arrayi)
return carry, leave
def srt(self, array):
globalii = 0
carry, leave = my.sort(array)
while len(self.sortedlist) != len(array):
if len(self.carry) == 1:
self.sortedlist.append(carry)
arrayt = leave
self.globali = 1
self.orderi = 0
carry, leave = my.sort(arrayt)
elif len(self.carry) == 0:
if len(self.leave) != 0:
arrayt = leave
self.globali = 1
self.orderi += 1
my.sort(arrayt)
else:
self.arrayt
globalii += 1
self.orderi = globalii
self.globali = 0
my.sort(arrayt)
self.orderi = 0
else:
arrayt = carry
carry = []
self.globali += 1
carry, leave += my.sort(arrayt)
my = sorting_class()
x = ['ac', 'bc' ,'ab', 'da']
my.srt(x)
© Stack Overflow or respective owner