I am using a sample from my book for testing a car class. I get this error and I am not sure why. I am only giving one argument that I can tell.
Here is my error code:
Traceback (most recent call last):
File "G:\Python_Stuff\car.py", line 79, in <module>
myCar.getVIN('V81FDX')
TypeError: getVIN() takes exactly 1 argument (2 given)

This is the code:

class Car:

    def __init__(self):# VIN, Make, Model, Color, Year, Price):
        self._VIN = ' ' #VIN
        self._Make = ' ' #Make
        self._Model = ' ' #Model
        self._Color = ' ' #Color
        self.setYear(' ')
        self.setPrice(0)



    def getOwner(self):
        return self._Owner


    def setVIN(self, VIN):
        self._VIN = VIN


    def getVIN(self):
        return self._VIN


    def setMake(self, Make):
        self._Make = Make


    def getMake(self):
        return self._Make


    def setModel(self, Model):
        self._Model = Model


    def getModel(self):
        return self._Model


    def setColor(self, Color):
        self._Color = Color


    def getColor(self):
        return self._Color


    def setYear(self, Year):
        if Year >= 1980:
            self._Year = Year
        else:
            print('invalid input for year, set to default value.')
            self._Year = 1980


    def getYear(self):
        return Year


    def setPrice(self, Price):
        if Price >= 5000:
            self._Price = Price
        else:
            print("invalid input for price, set to default value.")
            self._Price = 5000


    def __str__(self):
        display = "The car with the VIN '" + str(self._VIN) + "' is a '"
        display += str(self._Year) + "' " + str(self._Color) + " " + str(self._Make) + "\n"
        display += str(self._Model) + " with the price of '$" + str(self._Price) + "'"
        display += "\nOwner: " + str(self._Owner)
        return display

#Test class Car code test
if __name__ == '__main__':
  myCar = Car()
  myCar.getVIN('V81FDX')
  print myCar
  print
  
  myCar.getMake('Toyota')
  print myCar
  print

  myCar.getModel('Camry')
  print myCar
  print

  myCar.getColor('Grey')
  print myCar
  print

  myCar.setYear('2007')
  print myCar
  print

  myCar.setPrice(18000)
  print myCar
  print

Line 79 should be

myCar.getVIN()

instead of

myCar.getVIN('V81FDX')

Consider using python property builtin function. It is built for that.
Consider raising exception when the price is invalid.
Consider using new style classes if you run python 2.x.
If you have questions about that do not hasitate to ask...

I do not know what book you have, but it is either a java book or a very generic object orientated learning book. Python does not need getters-setters in most of the cases. Or a bad python book.

Why should VIN be a managed attribute? Why do you attempt to set the attribute with a getter?

All the questions ...

Getters and setters are evil. Evil, evil, I say! Python objects are not Java beans. Do not write getters and setters. This is what the ‘property’ built-in is for. And do not take that to mean that you should write getters and setters, and then wrap them in ‘property’.

http://tomayko.com/writings/getters-setters-fuxors

The link over is follow up from python is Not java.
http://dirtsimple.org/2004/12/python-is-not-java.html

thanks a lot for the help. This is a class for object programming.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.