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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:13:37+00:00 2026-06-17T07:13:37+00:00

I was testing some piece of code True = 2 print 1 – (1

  • 0

I was testing some piece of code

True = 2
print 1 - (1 == 1)
print True == (1 == 1)

Then I was expecting:

-1
True

But I got this instead:

0
False

So, I did what any python programmer would do: disassemble it.

def f():
    True = 2
    print 1 - (1 == 1)
    print True == (1 == 1)

2           0 LOAD_CONST               1 (2)
            3 STORE_FAST               0 (True)

3           6 LOAD_CONST               2 (1)
            9 LOAD_CONST               2 (1)
           12 LOAD_CONST               2 (1)
           15 COMPARE_OP               2 (==)
           18 BINARY_SUBTRACT     
           19 PRINT_ITEM          
           20 PRINT_NEWLINE       

4          21 LOAD_FAST                0 (True)
           24 LOAD_CONST               2 (1)
           27 LOAD_CONST               2 (1)
           30 COMPARE_OP               2 (==)
           33 COMPARE_OP               2 (==)
           36 PRINT_ITEM          
           37 PRINT_NEWLINE       
           38 LOAD_CONST               0 (None)
           41 RETURN_VALUE        

Then it was a bit clear, is using the COMPARE_OP (==). Witch should return a boolean but it appears that it returns a integer instead. Any ideas why?

Edit:

In short the lesson learned: Changing the values of True or False doesn’t change how the boolean logic is represented behind the scene.

  • 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-17T07:13:38+00:00Added an answer on June 17, 2026 at 7:13 am

    It seems to me that your misunderstanding was in thinking that treating True like a variable would actually change the results of boolean operations. It doesn’t. True is used by default to respresent, well, boolean truth, but it loses that functionality when you changes its value. However, that doesn’t change the rules for how booleans are treated with respect to integers.

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

Sidebar

Related Questions

I'm looking for some style advice for testing this piece of (Objective-)C++ code, I
For some testing purposes I have written a piece of code for measuring execution
We are testing some code to send email messages using Gmail from a form,
Hi I'm testing some CRUD operations in Nhibernate. I have 3 tests in this
I'm learning and testing some graph libraries and am running into a weird problem(but
I have this piece of code in my wordpress theme to load the pages
I came across this piece of code, and I can't quite figure out why
I've noticed this question posed for a related problem with unit testing, but my
So I've done unit testing some, and have experience writing tests, but I have
I've got a piece of code that I can't figure out how to unit

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.