473,569 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax error in ".py" file and globals variable values not available.

Hi,

I have a strange behaviour of python with pdb and import statement.
Here is the example code :

file my1.py:
import my2

file my2.py:
a=5
toto

I intentionnaly put a syntax error in file my2.py.

If I run "python -i my2.py" and run pdb I got :
NameError: name 'toto' is not defined
>>import pdb
pdb.pm()
-toto
>>print a
5

If I run "python -i my1.py" and run pdb I got :
NameError: name 'toto' is not defined
>>import pdb
pdb.pm()
-toto
>>print a
None

Why can't I get access to variable a in pdb when the process generating
the error came from an import statement ?

With python 2.3.5, it works fine and in the two cases I get the correct
value of 5 for variable "a".
with python 2.43,2.5.1,2.5. 2, it doesn't work and I get "None" value for
variable a.

Somebody can explain me this behaviour ?
Thanks.
--
Boutillier Alexis
Methodology engineer

Arteris SA
The Network-on-Chip Company TM
www.arteris.net

6 par Ariane Immeuble Mercure
78284 Guyancourt Cedex
France
Office: (+33) 1 61 37 38 71
Fax: (+33) 1 61 37 38 41
Al************* **@arteris.net
Aug 27 '08 #1
0 996

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3119
by: ulysses | last post by:
Hi, I use PyQt 3.8 non-commercial version in win32. I get a big question. I Can't show PY variable in QT filedialog as initially parameter. Code sample is following: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fileName="test.avi" def saveSomething(aString):
3
3990
by: | last post by:
Hi everybody, I'm sure there's a way to do this, but I can't find it. How can I execute another .py file from my first .py file without using an exec* command? They're both in the same directory, and it would be nice to have some run("another.py") type statement as opposed to a big exec with absolute pathnames and garbage like that. It...
5
5280
by: F. GEIGER | last post by:
Dear all, never thought that this could happen to me: I accidently deleted a ..py-file before I could back it up :-( However, the .pyc file is still there. Can I restore the .py file from the .pyc file somehow? Many thanks in advance Franz GEIGER
4
1812
by: martijn | last post by:
H! I'm trying to find a python function to use like this: -- maincode.py Include "apythonscript_function.py" -- end
1
2280
by: Beryl Small | last post by:
I have a web application in Visual Studio.Net 2003. On the click event of a button on my .aspx page, I use the following FileCopy SourceFile, DestinationFil the Sourcefile is on a mapped drive (s:\) on the server it returns the error "File not found" even though the file is there. The same code in the same place works fine if the file is...
6
2032
by: nibiery | last post by:
I am just getting started with Python, and I think I may be thinking about it wrong. I'd like to be able to work interactively with some code that I've got in a file. The only interpreted language I have much experience with is Tcl/Tk, and in that I would use "source file.tcl" in the console to load my source. Is there a similar command in...
5
2353
by: Jason Jiang | last post by:
Hi, How to get the name of the running .py file like the macro _FILE_ in C? Thanks. Jason
2
2204
by: ward.david | last post by:
I am using py2exe to generate an executable so that I can deliver my scripts as a EXE. I have a couple of file that are needed by the program that I do not want to include in the EXE because they are used for program configuration (similar to the way an INI file is used.) These file may change per installation, so I may need to edit them....
5
2144
by: ron.longo | last post by:
Is there any way that I can find the path of the main .py file of my application? For example, I have an application with some resources which are in a subdirectory: myPythonApp.py /resources image1
1
4698
by: cesco | last post by:
Hi, I need to instantiate an object (my_object) whose methods I have to use in two files (file1.py and file2.py) which are in the same directory. Is it possible to instantiate such object in the __init__.py file and then directly use it in file1.py and file2.py? If not, as I seem to experience, what is the best practice to follow in this...
0
7701
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.