Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:44:10+00:00 2026-05-30T21:44:10+00:00

The following code: #!/usr/bin/env python import mechanize class MechanizeSubclass(mechanize.Browser): def __init__(self, factory=None, history=None, request_class=None,

  • 0

The following code:

#!/usr/bin/env python                                                                                                                                       

import mechanize

class MechanizeSubclass(mechanize.Browser):
    def __init__(self,
                 factory=None,
                 history=None,
                 request_class=None,
                ):
        mechanize.Browser.__init__(self, factory, history, request_class)

    def open(self, url, data=None,
             timeout=mechanize._sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
        mechanize.Browser.open(self, url, data, timeout=timeout)

subclass = MechanizeSubclass()
subclass.open('https://uncjobs.northcarolina.edu/applicants/jsp/shared/Welcome_css.jsp')
print subclass.response().read()

generates the error

mechanize._response.httperror_seek_wrapper: HTTP Error 302: Moved Temporarily

I looked at the mechanize code and the Browser.open() method is defined as:

    def open(self, url, data=None,
         timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
    return self._mech_open(url, data, timeout=timeout)

and if I change the open() method in my subclass to match this:

class MechanizeSubclass(mechanize.Browser):
    ...
    def open(self, url, data=None,
         timeout=mechanize._sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
        return self._mech_open(url, data, timeout=timeout)

then it works fine. But I still don’t really understand why the first definition using mechanize.Browser.open(self, url, data, timeout=timeout) doesn’t work. Shouldn’t they be equivalent? This is with python 2.6 with mechanize 0.2.5.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:44:13+00:00Added an answer on May 30, 2026 at 9:44 pm

    The main difference between the first code snippet and the other two is that the openmethod is not returning anything (which in Python isthe same as returning the None object).

    That is, whatever code is calling the openmethod expects to have the object returned by _mech_open. Your first method just returns nothing.

    If you simply change the first implementation to:

    class MechanizeSubclass(mechanize.Browser):
        ...
        def open(self, url, data=None,
                 timeout=mechanize._sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
            return mechanize.Browser.open(self, url, data, timeout=timeout)
    

    You should not have this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the code here below: #!/usr/bin/env python import wx class MyForm(wx.Frame): def __init__(self): wx.Frame.__init__(self, None,
I have the following code: #!/usr/bin/ruby class Person def self.speak p = self.new puts
I have the following code: #!/usr/bin/env python import sys from PyQt4 import QtGui, QtCore
I have the following Python code: #!/usr/bin/env python2.6 class container(object): name = 'container' configuration
I have opened a shelve using the following code: #!/usr/bin/python import shelve #Module:Shelve is
the following code #!/usr/bin/env perl use strict; use warnings; my @foo = (0,1,2,3,4); foreach
I am trying to compare two Ruby Hashes using the following code: #!/usr/bin/env ruby
Suppose I have the following code: #!/usr/bin/env ruby -wKU h = {} h[[1, a]]
I have a script a.py : #!/usr/bin/env python def foo(arg1, arg2): return int(arg1) +
I have written a script in haskell named testscript with the following code: #!/usr/bin/env

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.