[Tutor] creating a class

James Mills prologic at shortcircuit.net.au
Wed Oct 6 00:36:02 CEST 2010

On Wed, Oct 6, 2010 at 4:16 AM, T MURPHY <tvsm at hotmail.com> wrote:
> how do i go about creating a class in python.

By using the "class" keyword.


class Fruit(object):

   def __init__(self, name)
      self.name = name

class Apple(Fruit):

   def __init__(self):
      super(Apple, self).__init__("apple")

apple = Apple()
print apple.name

For more information, I suggest you start reading
the python tutorial (1)


1. http://docs.python.org/tutorial/

-- James Mills
-- "Problems are solved by method"

More information about the Tutor mailing list