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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:00:32+00:00 2026-05-16T22:00:32+00:00

I make no claims to know anything at all about writing Python scripts or

  • 0

I make no claims to know anything at all about writing Python scripts or programming in general, but I’ve been tasked with writing one anyway that will have to operate on a wide variety of Python versions. I wrote, and did my testing on versions 2.3, 2.4 and all went well. Version 2.2 though is giving me fits and my google-fu must be weak because I’m coming up short with an answer.

The section of code that’s giving me problems:


commandnum = 0
for commandloop in arguments[0:]:
    if "java" in arguments[commandnum][0]:
        for argloop in arguments[commandnum]:
            if "Dcatalina.home" in argloop:
                instance = argloop.split("/")
            elif "-Xms" in argloop:
                xms = argloop.split("Xms")
            elif "-Xmx" in argloop:
                xmx = argloop.split("Xmx")
            elif "-XX:MaxPermSize" in argloop:
                permsize = argloop.split("=")
            elif "Dcatalina.base" in argloop:
                home = argloop.split("=")
                appdir = home[-1]+"/webapps"
                warfiles = []
                for war in os.listdir(appdir):
                    if fnmatch.fnmatch(war, '*.war'):
                        warfiles.append(war)
                thefiles = ",".join(warfiles)
        try:
            instance
        except NameError:
            instance = None
        if instance is not None:
            print "%s %s %s %s %s %s" % (instance[-2], xms[-1], xmx[-1], permsize[-1], appdir, thefiles)
    commandnum = commandnum + 1

I understand that this is UGLY and probably a BAD thing, but the error that I’m getting is in the string matching using ‘in’. From what I gather by googling, in Python 2.2 you’re limited to one character for string matching using ‘in’. What is the equivalent way in 2.2 to match on a string?

Upgrading machines to a modern version of Python is out of the question.

Any help/abuse is appreciated. Try to be gentle as this is the first thing of any size I’ve written outside of shell scripts and MS Basic on my TRS-80 CoCo in 1981.

  • 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-16T22:00:33+00:00Added an answer on May 16, 2026 at 10:00 pm

    Try using str.find, which returns -1 if the substring cannot be found.

    >>> s = "The quick brown fox"
    >>> s.find("The")
    0
    >>> s.find("brown")
    10
    >>> s.find("waffles")
    -1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to make sense of some claims that Appcelerator Titanium makes.
Make it on Linux. The reason to use more than one version of Vim,
i make one class file for jar. and this class have use wurfl. and
I am writing a custom WebDAV server in C#. One of the client test
1 to make an application, and everything's been working fine so far. However, out
I wish to make a large int array that very nearly fills all of
I've seen some claims that optimized PEG parsers in general cannot be faster than
This is related to my earlier post . I'd like to know why one
I decided to make one step forward on trying to understand Javascript and read
Okay, we all know attempting to parse HTML with Regex brings upon the wrath

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.