At first I have to admit, I did not wrote that much python code in my live, so please don't be so censorious, if I used wrong terminology.
But as far as I know you are try to call the inp()
method as a static method, because the x
in
for x in process:
x.inp()
isn't a new instance of the type Process
. It is just the type Process
, because you add the type Process
to your array and not a new instance.
for i in range(x):
process.append(Process)
So let us say the user enters 5
as the number of processes. Now your for loop will run five times and add items to your process
array. This array will now look like:
process = [[0:Process] [1:Process] [2:Process] [3:Process] [4:Process]]
which leads that you call five times Process.inp()
as a static method in
for x in process:
x.inp()
instead of an object method like
p1.inp()
p2.inp()
...
p5.inp()
To fix this issue you could change your code to
for i in range(x):
q = Process()
process.append(q)
q.no=i
and call later on
for x in process:
x.inp()
But this will leads to another error, since you have defined _init__(self)
and try to set three properties you did not defined in the __init__
signature.
So you could remove def __init__
or add these parameter:
def __init__(self, no, at, bt):
self.no=no
self.at=at
self.bt=bt
and create a new object with
q = Process(1, 2, 3)
At least I guess there is a little typo in your inp()
method. Did you really want to set ar
? I guess you mean self.at
.