[Tutor] Getting at object names
Bob Gailer
bgailer@alum.rpi.edu
Wed Apr 2 16:59:01 2003
--=======5AE64183=======
Content-Type: text/plain; x-avg-checked=avg-ok-2ABE61DC; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit
At 11:53 PM 4/2/2003 +0200, Charlie Clark wrote:
>And Bob came up with a really nice solution which I'm afraid I can't use
>because I'm currently running Python 2.1.2 on BeOS for development so I'll
>be going with Jeff's solution for the time being.
>
>#subclass list and give it a name attribute:
>class day(list):
> def __init__(self, name):
> self.name = name
> def set(self, items):
> self[:] = items
You can still use a class:
>>> import UserList
>>> class day(UserList.UserList):
>>> def __init__(self, name):
>>> self.name = name
>>> def set(self, items):
>>> self.data = items
>>> instance = day([1,2,3])
>>> instance
[1, 2, 3]
>>> instance.data = [3,4]
>>> instance
[3, 4]
>>> instance.set([3,4,5])
>>> instance
[3, 4, 5]
Bob Gailer
PLEASE NOTE NEW EMAIL ADDRESS bgailer@alum.rpi.edu
303 442 2625
--=======5AE64183=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-2ABE61DC
Content-Disposition: inline
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.463 / Virus Database: 262 - Release Date: 3/17/2003
--=======5AE64183=======--