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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:54:37+00:00 2026-05-26T09:54:37+00:00

I want to run pdb, step through the code, and at some point change

  • 0

I want to run pdb, step through the code, and at some point change the value pointed at by some name. So I might want to change the value pointed at by the name ‘stationLat’. But it seems I can’t. Here’s the example:

>>> import extractPercentiles
>>> import pdb
>>> pdb.run( "extractPercentiles.extractOneStation()" )
> <string>(1)<module>()->None
(Pdb) s
--Call--
> /scratch/extractPercentiles.py(96)extractOneStation()
-> def extractOneStation() :
(Pdb) tbreak 132
Breakpoint 3 at /scratch/extractPercentiles.py:132
(Pdb) c

Deleted breakpoint 3
> /scratch/extractPercentiles.py(132)extractOneStation()
-> stationLon = float(stationLoc[3])

So now I’m at a place where I would like to change the value of stationlat. Pdb appears to allow me to set stationLat to a new value, but when I inspect the value, it is unchanged:

(Pdb) stationLat
-34.171100000000003
(Pdb) stationLat = -40
(Pdb) stationLat   
-34.171100000000003
(Pdb) !stationLat = -40
(Pdb) stationLat
-34.171100000000003
(Pdb) 

You can see I tried using ! as well, without success.

The pdb manual says I should be able to change variables:

Commands that the debugger doesn’t recognize are assumed to be Python statements and are executed in the context of the program being debugged. Python statements can also be prefixed with an exclamation point (!). This is a powerful way to inspect the program being debugged; it is even possible to change a variable or call a function

Is this a question of scope? Is it to do with the way I have started pdb? I tried the embedded “pdb.set_trace” idiom and I got the same result.

Thanks for reading.

  • 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-26T09:54:38+00:00Added an answer on May 26, 2026 at 9:54 am

    This appears to be a bug in Python 2.6. You should be able to do this in Python 2.7.

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

Sidebar

Related Questions

i want run a php code when a user click a link and change
Why this code don't work,when i want run this code vwd 2008 express show
I want to run a jar file in editplus3 but I dont´n know how
I want to run some commands using the system() command, I do this way:
I want to run tail on a named pipe to facilitate some binary logfile
I'm using TFS2008 - soon to move to TFS2010 I want run code coverage
I want run a Bash script as root , but delayed. How can I
I want run %systemroot%\System32\reg.exe this file to do something, but when I use new
In c program, I want run c++ library function(s), but I don't know how
I want to run this piece of code Bitmap grayImage = (Bitmap)img.Clone(); for (int

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.