referencing an object attribute sort of indirectly from within list

python newbie mesteve_b at hotmail.com
Sat Nov 29 20:32:05 EST 2003


Is there anything that would get in the way of me being able to reference an object attribute, from within a list.

I have:
 #      one class here

  class BackupSet:
      fileGroupList = []
    
#      another class here

 class FileGroup:
     sourceDir = ''
     destinDir  = ''
     def __init__(self):
           self.sourceDir = 'c:\folder'
           self.destinDir = 'd:\folder'  


fileGroup = FileGroup()

backupSet = BackUpSet()

backupSet.fileGroupList.append(fileGroup)

# when i try to reference an attribute here, I just get 'none'

print bkset.fileGroupList[0].sourceDir                 or
print "%s" % bkset.fileGroupList[0].sourceDir
    

thanks
Steve  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20031130/3ee9e4dd/attachment.html>


More information about the Python-list mailing list