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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:31:00+00:00 2026-06-15T10:31:00+00:00

I started learning Python just today using Python 2.7 and I have a question

  • 0

I started learning Python just today using Python 2.7 and I have a question here about global variables True and False:

It seems I can overwrite the value of True and False as this:

False = True
# now the value of variable False is also true.
True = False
# because the value of False is true, after this the value of True is still true.

if True(or False):
    print 'xxxx'
else:
    print 'yyyy'

Now wether we put True or we put False as the if condition, it always prints ‘xxxx’.

Then how to recover from that fault situation? I imagine that we could use something like:

True = 1==1
False = 1!=1

but that seems bit dodgy to me. Is there any better way to do that?

Thanks.

(Also, it seems in Python 3.3 this action is no longer allowed?)

  • 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-15T10:31:02+00:00Added an answer on June 15, 2026 at 10:31 am

    The way to “recover” from this is to not let it happen.

    That said, you can always use the bool() type to access True and False again. (bool() always returns one of the two boolean singletons.)

    Example:

    >>> bool
    <type 'bool'>
    >>> bool(1)
    True
    >>> bool(1) is bool('true')
    True
    >>> True = False
    >>> True
    False
    >>> True is False
    True
    >>> False is bool()
    True
    >>> True = bool(1)
    >>> True is bool(1)
    True
    >>> True is False
    False
    >>> True is bool()
    False
    >>> bool()
    False
    >>> True is bool(2)
    True
    >>> True is bool('true')
    True
    >>> 
    

    If this is a simple True = 'something' binding, then what happens is that a new name True is created in the current namespace–the __builtins__ module is not altered. In this case you can simply delete (unbind) the “True” name in your namespace. Then Python will use the one defined in __builtins__ again.

    >>> dir()
    ['__builtins__', '__doc__', '__name__', '__package__']
    >>> True is __builtins__.True
    True
    >>> True = 'redefined'
    >>> __builtins__.True is True
    False
    >>> del True
    >>> __builtins__.True is True
    True
    

    None of this is possible in Python 3 because True and False are no longer names (variables) but keywords.

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

Sidebar

Related Questions

I just started using/learning Python and have some questions. I have a text file
I've just started learning about Gimp scripting using Python, and was wondering, how do
I just started learning python and django and I have a question. I got
I just started learning Python today. I have a list: [text:u'Oranges', text:u'Apples', empty:'', empty:'']
We just started learning about class inheritance and attribute lookup in python. I have
I am new to python and just started learning it today. I have installed
Just started learning python (3.2) and have a question. I have created a some
I have just started learning python version 3 and trying to create a file
I've just started learning Python today. I've been reading a Byte of Python. Right
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python

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.