I am getting following error when tried as you suggested. self.event = [] #Create an empty list, bind to the name "event" under the "self" namespace self.event.append(Event()) #Create an event object and append to the end of the list
*class Event(): ^ SyntaxError: invalid syntax* On Wed, May 28, 2008 at 1:07 AM, Patrick Mullen <[EMAIL PROTECTED]> wrote: > I don't know if this will go through (my posts seem to have become blocked > lately), but I'll give it a shot anyhow. > > You seem to be under a misconception that a python list is similar to a > list in say, Java or other languages that have a rigid idea of variables and > types. In python, a list is a list of objects - any type of object can be > stored in a list. Just as you don't declare types for variables, you also > don't declare types for lists. Here is your modified code: > > class Event(): > def __init__(self, cameraEventType="", zone=99, setDay="",setTime ="", > clrTime=""): > self.cameraEventType = cameraEventType > self.zone = zone > self.setDay = setDay > self.setTime = setTime > self.clrTime = clrTime > > class EventTimeFilter: > def __init__(self): > self.event = [] #Create an empty list, bind to the name "event" > under the "self" namespace > self.event.append(Event()) #Create an event object and append > to the end of the list > > > Python won't stop you from putting other objects into self.event besides > Event objects, but in practice this isn't often an issue. The real benefit, > is if you subclass event or make some other type of object that is similar > to events, with maybe some of the same fields, you can still store them in > the list and it will play along with the rest of your code. > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Regards Alok Kumar
-- http://mail.python.org/mailman/listinfo/python-list