---------- Forwarded message ----------
Date: Fri, 25 Nov 2005 08:59:30 -0400
From: mike donato <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: [Tutor] TRULY NEWBIE - MENTOR NEEDED

Dan, what I meant was that the program does not run. Why?
Thanks


From: Danny Yoo <[EMAIL PROTECTED]>
To: mike donato <[EMAIL PROTECTED]>
CC: [email protected]
Subject: Re: [Tutor] TRULY NEWBIE - MENTOR NEEDED
Date: Tue, 22 Nov 2005 14:46:14 -0800 (PST)



On Tue, 22 Nov 2005, mike donato wrote:

> Greetings, I am new student to programming and am experimenting with
> PYTHON.  From what I have read, seems to be a very versatile language.
> In the following excercise I am getting an error
>
> class String(str, Object):

[class definition cut]
>
> Traceback (most recent call last):
>   File "<pyshell#0>", line 11, in -toplevel-
>     class String(str, Object):
> NameError: name 'Object' is not defined


Hi Mike,

The error is true: Python doesn't know of any class named 'Object'.  What
you may be looking for is the 'object' class (lowercase 'o').

Good luck!


_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
#
# This file contains the Python code from Program 4.5 of
# "Data Structures and Algorithms
# with Object-Oriented Design Patterns in Python"
# by Bruno R. Preiss.
#
# Copyright (c) 2003 by Bruno R. Preiss, P.Eng.  All rights reserved.
#
# http://www.brpreiss.com/books/opus7/programs/pgm04_05.txt
#
class Array(object):

   def __len__(self):
       return len(self._data)

   def setLength(self, value):
       if len(self._data) != value:
           newData = [ None for i in xrange(value) ]
           m = min(len(self._data), value)
           for i in xrange(m):
               newData[i] = self._data[i]
           self._data = newData

   length = property(
       fget = lambda self: self.__len__(),
       fset = lambda self, value: self.setLength(value))

   # ...


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to