Maybe it's early morning brain...The line called out is:
self.new_queue = Queue("New", sim)
and the error says:
Error:
TypeError: Queue.__init__() takes from 1 to 2 positional arguments but 3 were given
and the declaration says:
class Queue:
def __init__(self, name: str, sim):
Please post the code and errors using the bbtags. Can't tell much from images.
(Oct-14-2023, 12:28 PM)menator01 Wrote: [ -> ]Please post the code and errors using the bbtags. Can't tell much from images.
Can’t find how to do it. Tried but doesn’t seem to do the trick…
This example runs with no error.
class Queue:
def __init__(self, name: str, sim):
pass
new_queue = Queue("New", True)
The error message says that Queue is defined like this:
class Queue:
def __init__(self, name=""):
I think Queue is not what you think it us. Is Queue a class you wrote, or is it imported?
If you imported
Queue
from module
queue
, then you can use only one argument, which is the
maxsize
of the queue. The modules
asyncio
and
multiprocessing
modules have also a Queue implementation, which takes also
maxsize
.
If
Queue
is your implementation in a different module, then pay attention if you overload with an import your class.
from utils import Queue
from queue import Queue
# Queue is now form queue
# different order
from queue import Queue
from utils import Queue
# Queue is now form utils
Another possible error:
class Queue:
def __init__(self, name, simu): ...
# later in code
class Queue:
def __init__(self, name): ...
# calling now Queue, calls the latest definition of Queue,
# which takes only one argument. (the self is given implicit and is the instance of the class)