Trying to subclass mechanize.Browser class:
from mechanize import Browser
class LLManager(Browser, object):
IS_AUTHORIZED = False
def __init__(self, login = "", passw = "", *args, **kwargs):
super(LLManager, self).__init__(*args, **kwargs)
self.set_handle_robots(False)
But when I make something like this:
lm["Widget[LinksList]_link_1_title"] = anc
then I get an error:
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
lm["Widget[LinksList]_link_1_title"] = anc
TypeError: 'LLManager' object does not support item assignment
Browser class have overridden method __getattr__ as shown:
def __getattr__(self, name):
# pass through _form.HTMLForm methods and attributes
form = self.__dict__.get("form")
if form is None:
raise AttributeError(
"%s instance has no attribute %s (perhaps you forgot to "
".select_form()?)" % (self.__class__, name))
return getattr(form, name)
Why my class or instance don't get this method as in parent class?