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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:29:33+00:00 2026-06-14T03:29:33+00:00

Complete newbie question. I am developing a class for searching a movie database using

  • 0

Complete newbie question.

I am developing a class for searching a movie database using an API.

Here is how you make a query using the movie title and year from within the Python interpreter:

import moviesearch

movie_db = moviesearch.MovieSearch()
result = movie_db.search('Clockwork Orange', year='1971')
print result

Doing this particular query yields one result from the service I am using.

To save typing for testing, I have created the following script m.py:

from sys import argv
import moviesearch

script, movie_name, params = argv

movie_db = moviesearch.MovieSearch()
result = movie_db.search(movie_name, params)
print result

When I execute this script like so:

python m.py 'Clockwork Orange', year='1971'

the service yields two results.

So this means that there is something wrong with the way I am formatting my parameters when I am testing the class with the script. Can someone please tell me what I am doing wrong?

I am not including the class for querying the movie database because I don’t think that’s necessary for figuring out what’s wrong. What I need to know is how to properly format my parameters when using the script so that it executes exactly as it does in the example above where I am using the class directly from the Python interpreter.

Thanks in advance for any help.

  • 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-14T03:29:35+00:00Added an answer on June 14, 2026 at 3:29 am

    When you do this in the shell (I’m assuming a *nix platform with an sh-compatible shell; Windows is probably slightly different):

    python m.py 'Clockwork Orange', year='1971'
    

    The sys.argv list will be:

    ['m.py', 'Clockwork Orange,', 'year=1971']
    

    So, when you do this:

    script, movie_name, params = argv
    

    You end up with movie_name set to the string 'Clockwork Orange,' (with an extra comma), and params set to the string 'year=1971'. So, your call is ultimately:

    result = movie_db.search('Clockwork Orange,', 'year=1971')
    

    This is not the same as:

    result = movie_db.search('Clockwork Orange', year='1971')
    

    So, how do you get what you want?

    Well, you can parse the params, with code something like this:

    params = dict(pair.split('=') for pair in argv[2:])
    result = movie_db.search(movie_name, **params)
    

    The first line will give you a dict with {'year': '1971'}. Then you can use the ** syntax to forward that dict as the keyword arguments to the function.

    Finally, you should take out the extra comma in the arguments you use to run the script. (You could write code to strip it, but it seems like it’s just a typo, so the better fix is to not make that typo.)

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

Sidebar

Related Questions

Forgive the complete newbie question here - I know this is really basic stuff,
Complete newbie question here: I'm just playing with C# for the first time and
I'm a complete newbie when it comes to OCaml. I've only recently started using
I'm a complete newbie to LINQ, so please bare with my stupid questions. Using
I'm really new at network-programming, so I hope this isn't a complete Newbie-question. I
This may be a newbie question, But let's say I have a database table
i am a newbie to the design patterns and here is my question if
a newbie needs some help with logic flow: I'm using the Auto Complete extender
I'm a complete newbie to programming and am having problems implementing a SELECT query
I'm a complete newbie to all this stuff, and I'm developing a plugin. I

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.