I have a python3 class with the following code
class Cow:
def __init__(self, *bovines):
for i in bovines:
self.i = i
print(i)
def moo(a,b):
print(a)
animal = Cow
animal.moo('a','b')
It prints, correctly, a
.
However, if I run the following (the only difference being that animal = Cow('Annie')
instead of animal = Cow
)
class Cow:
def __init__(self, *bovines):
for i in bovines:
self.i = i
print(i)
def moo(a,b):
print(a)
animal = Cow('Annie')
animal.moo('a','b')
Then moo
returns the error
TypeError: moo() takes 2 positional arguments but 3 were given
I imagine this has something to do with the function accepting whatever is __init__
'd as an argument, but I'm not sure how to work around this.
Thanks for any help!