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

  • Home
  • SEARCH
  • 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 389553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:52:41+00:00 2026-05-12T15:52:41+00:00

I sent a reference to a bool object, and I modified it within a

  • 0

I sent a reference to a bool object, and I modified it within a method. After the method finished its execution, the value of the bool outside the method was unchanged.

This leads me to believe that Python’s bools are passed by value. Is that true? What other Python types behave that way?

  • 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-12T15:52:42+00:00Added an answer on May 12, 2026 at 3:52 pm

    Python variables are not “references” in the C++ sense. Rather, they are simply local names bound to an object at some arbitrary location in memory. If that object is itself mutable, changes to it will be visible in other scopes that have bound a name to the object. Many primitive types (including bool, int, str, and tuple) are immutable however. You cannot change their value in-place; rather, you assign a new value to the same name in your local scope.

    In fact, almost any time* you see code of the form foo = X, it means that the name foo is being assigned a new value (X) within your current local namespace, not that a location in memory named by foo is having its internal pointer updated to refer instead to the location of X.

    *- the only exception to this in Python is setter methods for properties, which may allow you to write obj.foo = X and have it rewritten in the background to instead call a method like obj.setFoo(X).

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

Sidebar

Ask A Question

Stats

  • Questions 196k
  • Answers 196k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The most likely culprit is that you aren't including MicrosoftAjax.js… May 12, 2026 at 7:09 pm
  • Editorial Team
    Editorial Team added an answer I don't think that will work because ASP.NET MVC relies… May 12, 2026 at 7:09 pm
  • Editorial Team
    Editorial Team added an answer First of all, you might want to use the post-receive… May 12, 2026 at 7:09 pm

Related Questions

A few days ago I needed to toggle a bool , and I ended
I'm writing a parallel evolutionary algorithm library using C++, MPI and CUDA. I need
I'm using the iPhone SDK 3.0, but I think this is a general misunderstanding
I'm pretty sure this is possible, because I'm pretty sure I've seen it done.
How do you set the authorization for a Service Reference in web.config? I'm writing

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.