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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:35:07+00:00 2026-05-21T07:35:07+00:00

I am using threads in a python program and recently found a problem where

  • 0

I am using threads in a python program and recently found a problem where a float is not being interpreted correctly and whenever I go to print it out in pdb or in a logging statement, it shows up correctly most of the time.

Oddly, it takes a different amounts of prints to show up in these two threads I just ran. Also the first two prints use the same format, but the value still changes in thread 1.

for x in imports:
    if float(x.prob) == 0.0:
        logging.debug(float(x.prob))
        logging.debug(float(x.prob))
        logging.debug(x.prob)
        logging.debug(str(x.prob))
        logging.debug(str(float(x.prob)))
        import pdb; pdb.set_trace()

[DEBUG] (Thread-1  ) 0.0
[DEBUG] (Thread-1  ) 0.0592
[DEBUG] (Thread-1  ) 0.0592
[DEBUG] (Thread-1  ) 0.0592
[DEBUG] (Thread-1  ) 0.0592
[DEBUG] (Thread-2  ) 0.0
[DEBUG] (Thread-2  ) 0.0
[DEBUG] (Thread-2  ) 0
[DEBUG] (Thread-2  ) 0.0592
[DEBUG] (Thread-2  ) 0.0592

and

(Pdb) float(x.prob) == 0.0
False

What is the cause?
what can I do so it’s interpreted correctly the first time?

Similar to this question: https://stackoverflow.com/questions/2485338/pdb-show-different-variable-values-than-print-statements

  • 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-21T07:35:07+00:00Added an answer on May 21, 2026 at 7:35 am

    Its pretty impossible to tell from what you’ve posted. Floats don’t switch from 0.0 to ~0.05 randomly, something is changing the value stored in that memory location (variable). Are you setting the value from other thread?

    Also, be aware that in your demo code, if you’re looking for x.prob to have the value of 0.0592 from the beginning, it will fail the equality test in the if statement and never trigger your print statements.

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

Sidebar

Related Questions

I have a problem with Observer-Pattern and deadlock using threads. package observerDeadLock; import java.util.Observable;
First off I want to say that I am not using threads or multiple
I'm programming a simple pyS60 app, not really done anything with python or using
It seems that asynchronous signals in multithreaded programs are not correctly handled by Python.
We have a Python application that polls directories using threads and inotify watchers. We
I want to stream a binary data using python. I do not have any
I have a program that uses OpenGL combined with Cocoa and Python using PyObjC.
I have a python program with 2 threads ( let's name them 'source' and
I'm trying to learn how to use threading in a python program. I'm using
Visual Studio C++ 2008 I am using threads. However, I have this warnings and

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.