Reputation: 111
I'm doing Simulation of Round-Robbin algorithm and code listed below gives me error
RR.Przesuniecie[Oczekujace_procesy]
TypeError: 'instancemethod' object is unsubscriptable
Here piece of code:
class RR:
def Przesuniecie(self, Lista):
if(len(Lista) < 2):
return Lista
else:
head = Lista[0]
for i in range(1, len(Lista)):
Lista[i-1] = Lista[i]
Lista[-1] = head
return Lista
def Symulacja(self, n ,kwant):
Oczekujace_procesy = []
[....]
if(timer == kwant):
RR.Przesuniecie[Oczekujace_procesy]
I have no idea why it gives me error. There just piece of code, on list Oczekujace_procesy
I'm doing some operations.
Upvotes: 1
Views: 2352
Reputation: 77007
In your method, def Symulacja(self, n ,kwant):
, you are accessing Przesuniecie
wrongly as RR.Przesuniecie[Oczekujace_procesy]
. Przesuniecie
happens to be an instance method, and not a class method, so it isn't so accessible.
You can read about the differences between the two in Difference between Class and Instance methods.
Instead, access it as self.Przesuniecie(Oczekujace_procesy)
Upvotes: 3
Reputation: 799120
Punctuation matters.
self.Przesuniecie(Oczekujace_procesy)
Upvotes: 1