referencing an object attribute sort of indirectly from within list

python newbie mesteve_b at hotmail.com
Sun Nov 30 07:28:06 EST 2003


Thanks for the help both of you. Got that under control.
  "python newbie" <mesteve_b at hotmail.com> wrote in message news:pMbyb.61903$LN3.57968 at newssvr25.news.prodigy.com...
  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/f3c30c65/attachment.html>


More information about the Python-list mailing list