HI
I was having a look into classes and i noticed i saw a lot of things like

class fruitcake(object):
    pass

my question is what is the point of the "object" being in the class arguments as it is a Built In Function and i couldn't work out what putting it there did

Well basically you have a class called fruitcake, and (object) is the varible you defined. So object may be like this:

object = rectangle(100,45)

that you defined at the beginning of the program. So you use that varible "object" in the class. Here's an example of a class using Shape:

rectangle = Shape(100,45)

def __init__(self,x,y):
        self.x = x
        self.y = y
        description = "This shape has not been defined"
        author = "Nobody has claimed to make this shape"
        def area(self):
            return self.x * self.y
        def perimeter(self):
            return 2 * self.x + 2 * self.y
        def describe(self,text):
            self.description = text
            def authorName(self,text):
                self.author = text
                def scaleSize(self,scale):
                    self.x = self.x * scale
                    self.y = self.y * scale

Hope that helped.

Tondeuse.

HI
I was having a look into classes and i noticed i saw a lot of things like

class fruitcake(object):
    pass

my question is what is the point of the "object" being in the class arguments as it is a Built In Function and i couldn't work out what putting it there did

Class object is the base class that is at the top of any inheritance tree. It designates the new style Python class (Python24 and higher) having some additional feautures like __slots__ which prevents new variable creation outside the class. __slots__ also replaces the usual __dict__ in the class to give speed improvement.

To show it's methods use:

print dir(object)

Also, do not use 'object' for variable name.

ich1,

A class that inherits from object is called a "new-style" class. "Old-style" or "classic" classes are likely to be deprecated some time in the future.

This question has already been answered. Start a new discussion instead.