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

  • Home
  • SEARCH
  • 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 9200589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:48:07+00:00 2026-06-17T22:48:07+00:00

I had this class that performed perfectly in Linux. class UrlRequestor(object): def __init__(self, url,

  • 0

I had this class that performed perfectly in Linux.

class UrlRequestor(object):
    def __init__(self, url, headers, data):
        self.url = url
        self.headers = headers
        self.request = urllib2.Request(url)
        self.data = data
        self.data = data
        if self.data:
            self.request.add_data(self.data)
        for headerName, headerContent in self.headers.iteritems():
            self.request.add_header(headerName, headerContent)
    def open(self):
        self.content = urllib2.urlopen(self.request)
    def getHeader(self, headerName):
        return self.content.info().getheader(headerName)
    def getReturnData(self):
        return dict(json.loads(self.content.read()))
    def getRawReturn(self):
        return self.content.read()}

Which I have been trying to run on windows – with many errors including indentation I finally became stuck at this point.

I am apparently missing a ‘positional argument’ for the add_data method. Although I believe this is a symptom of a larger problem.

Here is the code as I have it.

class UrlRequestor(object):
    def __init__(self, url, headers, data):
        self.url = url
        self.headers = headers
        self.request = urllib2.Request(url)
        self.data = data
        self.data = data
        if self.data:
            self.request.add_data(self.data)
        for headerName, headerContent in self.headers.iteritems():

            self.request.add_header(headerName, headerContent)
    def open(self):
        self.content = urllib2.urlopen(self.request)
    def getHeader(self, headerName):
        return self.content.info().getheader(headerName)
    def getReturnData(self):
        return dict(json.loads(self.content.read()))
    def getRawReturn(self):
        return self.content.read()

I don’t mind reading, I don’t mind point in the right direction. At this point I am pretty stumped, and a little pointing wouldn’t hurt.

Many thanks guys.

EDIT********************************

For future information check the python version, installed 2.7.3 and ran exactly same code as on linux without a problem.

  • 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-06-17T22:48:08+00:00Added an answer on June 17, 2026 at 10:48 pm

    If you’re working with Python 2.7.x, then place import urllib2 at the beginning of your file.

    If you’re working with Python 3.x, then observe the note regarding the change to the urllib family of libraries in Python 3.x:

    Note: The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.

    For your case, the library you want to use can be found in urllib.request.

    Alternatively, on your Windows machine, elect to use the same version of Python that you have on your Linux box. There may be some other caveats in using Python 3.x on two platforms with the same code base that you’re not entirely accounting for.

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

Sidebar

Related Questions

For this assignment I had to create my own string class. I initially wrote
I had a Scala class as follows: class ClassA(val name: String) { println(this is
I had this nasty bug that disappeared in the past but now after quite
I had this doubt for sometime now, some people say that there's no such
So, I have this code that grabs a bunch of data from the database,
Say I had a User class like this: public class User { public bool
Suppose I had a PageCollectionView of ItemType, where T is some user class that
We're using a class library that performs calculations on 3D measurement data, it exposes
Had this working; at one stage. The problem is the following text is now
I had this weird problem a little while ago and haven't been able to

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.