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 8950669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:29:37+00:00 2026-06-15T13:29:37+00:00

I was wondering if there are known workarounds to some odd behavior I’m seeing

  • 0

I was wondering if there are known workarounds to some odd behavior I’m seeing with python’s urlparse.

Here are some results from a couple of lines in the python interpeter:

>>> import urlparse
>>> urlparse.parse_qsl('https://localhost/?code=bork&charlie=brown')
[('https://localhost/?code', 'bork'), ('charlie', 'brown')]

In the above example, why is the key for the first value ‘https://localhost/?code’? Shouldn’t it just be ‘code’? Note: parse_qs has the same bad behavior.

>>> urlparse.urlparse('abcd://location/?code=bork&charlie=brown')
ParseResult(scheme='abcd', netloc='location', path='/?code=bork&charlie=brown', params='', query='', fragment='')
>>> urlparse.urlparse('https://location/?code=bork&charlie=brown')
ParseResult(scheme='https', netloc='location', path='/', params='', query='code=bork&charlie=brown', fragment='')

In the above example note that the query string doesn’t always get put into the query value. Why does the protocol matter at all? Shouldn’t the query field always get the query string? Testing with ‘ftp’ or other well known protocols seems to also be unhappy.

  • 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-15T13:29:38+00:00Added an answer on June 15, 2026 at 1:29 pm

    urlparse.parse_qsl (and urlparse.parse_qs) are methods intended for the query part of the request (the string after the ?).

    Maybe you want to use a method that understands whole URLs first (urlparse.urlparse), and then pass the query from the result to urlparse_qsl:

    >>> import urlparse
    >>> myurl = urlparse.urlparse('https://localhost/?code=bork&charlie=brown')
    >>> print myurl
    ParseResult(scheme='https', netloc='localhost', path='/', params='', query='code=bork&charlie=brown', fragment='')
    >>> print myurl.scheme
    https
    >>> print urlparse.parse_qs(myurl.query)
    {'charlie': ['brown'], 'code': ['bork']}
    

    The scheme matters, because although the query exists in the generic syntax, some protocols may not support them.

    See also:

    http://en.wikipedia.org/wiki/URI_scheme (check out the official registered schemes)

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

Sidebar

Related Questions

I'm wondering if there is something like Hotswap/HotDelpoy/JRebel (known from Java World) in .NET
I was wondering - are there any known techniques to control access to a
Hi I was wondering if there is any known way to get rid of
Just wondering if there's a known way of getting a Mono System.Windows.Forms application to
I was wondering if there were any big known issues out there. After upgrading
I'm wondering, is there a known font safe alphabet? I tried googling this to
I was wondering if there is a known technique for saving and using variables
I was wondering if there are known methods to detect (or give a best
i just read this article : https://developer.mozilla.org/en/HTTP_Caching_FAQ There's a firefox behavior (and some other
I was wondering if there is any known way of moving MATLAB figures 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.