Setting property for current class from property in an different class...

Christopher Reimer christopher_reimer at yahoo.com
Wed Sep 6 22:24:40 EDT 2017


Greetings,

My web scraper program has a top-level class for managing the other 
classes. I went to set up a property for the top-level class that 
changes the corresponding property in a different class.

class Scraper(object):

     def __init__(self, user_id, user_name):
         self.requestor = Requestor(user_id, user_name)

     @property
     def page_start(self):
         return self.requestor.page_start

     @page_start.setter
     def page_start(self, number):
         self.requestor.page_start = number


I get the following error for @page_start.setter when I try to run the code.

     AttributeError: 'Scraper' object has no attribute 'requestor'

That's either a bug or I'm doing it wrong. Or maybe both?

Thank you,

Chris R.




More information about the Python-list mailing list