473,574 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Puzzling output when executing .pyc file directly

I created a simple test file called "tester.py" :
def dostuff(obj):
print "Doing stuff with %s now..." % obj
return len(str(obj))
x = "things"
if __name__ == "__main__":
print dostuff(x)
imported it into Python, then exited the current Python
session. Then I compared the results of calling the .py
file with those from calling the .pyc file:
bash-2.03$ python tester.py
Doing stuff with things now...
6

bash-2.03$ python tester.pyc
Doing stuff with things now...
6
run_pyc_file: nested_scopes: 0
Can anyone tell me what the run_pyc_file line is doing
in the output of the .pyc file? Is that normal
behaviour when calling a .pyc file?

For my sins, I am using Python 2.1.1 on sunos5.

Thanks,

--
Steven.

Dec 14 '05 #1
2 1274
Steven D'Aprano wrote:
I created a simple test file called "tester.py" :
def dostuff(obj):
print "Doing stuff with %s now..." % obj
return len(str(obj))
x = "things"
if __name__ == "__main__":
print dostuff(x)
imported it into Python, then exited the current Python
session. Then I compared the results of calling the .py
file with those from calling the .pyc file:
bash-2.03$ python tester.py
Doing stuff with things now...
6

bash-2.03$ python tester.pyc
Doing stuff with things now...
6
run_pyc_file: nested_scopes: 0
Can anyone tell me what the run_pyc_file line is doing
in the output of the .pyc file? Is that normal
behaviour when calling a .pyc file?
No and no :-)
For my sins, I am using Python 2.1.1 on sunos5.

Don't know whether that was a 2.1.1-specific problem, but that's
certainly not how 2.4.1 behaves. But then, you knew that already, didn't
you?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Dec 14 '05 #2
Steven D'Aprano wrote:
bash-2.03$ python tester.pyc
Doing stuff with things now...
6
run_pyc_file: nested_scopes: 0
Can anyone tell me what the run_pyc_file line is doing
in the output of the .pyc file? Is that normal
behaviour when calling a .pyc file?

For my sins, I am using Python 2.1.1 on sunos5.


"that's just a random debugging printf left in by mistake"

http://mail.python.org/pipermail/pyt...il/096463.html

Peter

Dec 14 '05 #3

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

Similar topics

4
2435
by: Avi Kak | last post by:
Is there a Python function in any of the standard-distribution modules that does what the backticks do in Perl? I want to run an external command and I'd like its output to be captured directly in my Python script in the form of a string object. The function os.system() or any of the
3
4890
by: Jorge Cecílio | last post by:
Hi! I would like to export some MS-Access reports output to pdf. However, the only possibility offered by Access (afaik) for me to export formatted output is snp (snapshot) (I use MS-Office XP Prof. 2002 version). With formatted output I mean the *exactly* output I produce from executing my report (information is gathered from an ODBC...
11
2045
by: Hello | last post by:
Hi every one. The famous Hello code below written by C++. through its mother program "Visual studio 2005" When I make copy to all files of this program and click on .EXE file away from the mother program, the output disappears immediately. Can any person add a line (may related to" Keypress", so that the output can stay without...
73
2753
by: Rajeet Dalawal | last post by:
Good day group. I was asked in an interview to explain the behavior of this program. void main() { char *s = "abc"; int *i = (int *) s; printf("%x", *i); }
0
7794
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...
0
7710
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6437
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
5296
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
3738
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2230
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
1332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1051
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.