473,378 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 986

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

Similar topics

4
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:...
3
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...
5
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...
4
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
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...
6
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...
5
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
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...
5
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.