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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:06:15+00:00 2026-05-23T15:06:15+00:00

An if statement in Python evaluates and it appears returns the non-expected value. p

  • 0

An if statement in Python evaluates and it appears returns the non-expected value.

p = sub.Popen('md5.exe -n md5.exe',stdout=sub.PIPE,stderr=sub.PIPE)
md5, errors = p.communicate()
print md5
abc = "8D443F2E93A3F0B67F442E4F1D5A4D6D"
print abc
if md5 == abc: print 'TRUE'
else: print 'FALSE'

repr(md5) is '8D443F2E93A3F0B67F442E4F1D5A4D6D\r\n'.

The 2 strings are the same, but yet it evaluates and prints FALSE.

What’s happening here, and how can this be solved?

  • 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-23T15:06:16+00:00Added an answer on May 23, 2026 at 3:06 pm

    Your md5 contains trailing whitespace, which the abc value does not have. Most command-line programs end with a line break because it can be disruptive to shell users not to. It’s possible to output this to the standard error stream so as not to interfere with programs like yours, but this is often not done.

    You can use the string method .strip() to remove all whitespace from the beginning and end of a string. For example,

    md5 = md5.strip()
    

    If you were using Python 3, the same error could have be caused because the Subprocess object’s .communicate() method returns bytes objects, which are not be equal to any strings.

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

Sidebar

Related Questions

The yield statement in python allows simple iteration from a procedure, and it also
I'm having a hard time with the setup statement in Python's timeit.Timer(stmt, setup_stmt). I
Does Javascript or jQuery have sometime like the in statement in Python? a in
I need to realize a complex if-elif-else statement in Python but I don't get
In python you can use a tuple in a formatted print statement and the
in the python console the following statement works perfectly fine (i guess using eval
Can we initialize Python objects with statement like this: a = b = c
I need to include a copyright statement at the top of every Python source
Is there a Bash equivalent to the Python's pass statement?
Is there any alternatives to the print statement for output in Python. Also, how

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.