Struct usages in Python

Alok Kumar alokkat at gmail.com
Wed May 28 08:41:06 EDT 2008


while traversing I get out of index error as mentioned below.


class EventTimeFilter:

   def __init__(self):
*           self.event = [Event()]*


   def populateScheduleData(self):

       self.doc = libxml2.parseFile(self.FILENAME)
       for eachcamera in
self.doc.xpathEval('SetDeviceConfiguration/Camera/.'):
            cameraIndex = eachcamera.get_properties()
            #print cameraIndex
            index = int(cameraIndex.content,10)
            print index

            xpathEventType = 'SetDeviceConfiguration/Camera[@cameraIndex=' +
cameraIndex.content +']/Filter/Event'
            for searchResults in self.doc.xpathEval(xpathEventType):
             eventType = searchResults.get_properties()

            * self.event[index-1].cameraEventType = eventType.content #
Error*

*#Error as below*
    self.event[index-1].cameraEventType = eventType.content
IndexError: list index out of range

Any guidance why I am getting *list index out of range error*?
index value runs from 1 to 4.
Thanks for all your help.
Alok

On Wed, May 28, 2008 at 1:09 AM, Casey McGinty <casey.mcginty at gmail.com>
wrote:

>
>            self.event[] = Event()   *# Seems this is not allowed ?? *
>>
>
> self.event = [Event()]
>
> - Casey
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Regards
Alok Kumar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080528/c975c73d/attachment-0001.html>


More information about the Python-list mailing list