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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:45:06+00:00 2026-05-11T08:45:06+00:00

Alright, so my title sucked. An example works better: input = ‘check yahoo.com’ I

  • 0

Alright, so my title sucked. An example works better:

input = 'check yahoo.com' 

I want to parse input, using the first word as the ‘command’, and the rest of the string as a parameter. Here’s the simple version of how my non-Pythonic mind is coding it:

if len(input) > 0:     a = input.split(' ')     if a[0] == 'check':         if len(a) > 1:             do_check(a[1])     elif a[0] == 'search':         if len(a) > 1:             do_search(a[1]) 

I like Python because it makes normally complicated things into rather simple things. I’m not too experienced with it, and I am fairly sure there’s a much better way to do these things… some way more pythonic. I’ve seen some examples of people replacing switch statements with dicts and lambda functions, while other people simply recommended if..else nests.

  • 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. 2026-05-11T08:45:07+00:00Added an answer on May 11, 2026 at 8:45 am
    dispatch = {   'check': do_check,   'search': do_search, } cmd, _, arg = input.partition(' ') if cmd in dispatch:     dispatch[cmd](arg) else:     do_default(cmd, arg) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I have my urls set up to rewrite news_item.php?id=1 to blog/1/Title-of-post. This works
Alright, hard to phrase an exact title for this question, but here goes... I
Alright. I am using a Modal box pop up window to display business details
Alright, probably not the best title, but meh. I have the following code inside
Alright, I know my title is a little obscure but it best describes the
Alright, I have a fairly simple design. class Update(models.Model): pub_date = models.DateField() title =
Possible Duplicate: How can I remove external links from HTML using Perl? Alright, i'm
Alright, I am not completely sure that I worded the title right, but I
Alright, I'm using a page creating class I found as below but when I
Trying to parse out lat/lon from a google maps rss feed: $file = http://maps.google.com/maps/ms?ie=UTF8&hl=en&vps=1&jsv=327b&msa=0&output=georss&msid=217909142388190116501.000473ca1b7eb5750ebfe;

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.