Puzzling output when executing .pyc file directly

S

Steven D'Aprano

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,
 
S

Steve Holden

Steven said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top