如何避免.pyc文件? [英] How to avoid .pyc files?

查看:192
本文介绍了如何避免.pyc文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以运行python解释器而不生成已编译的.pyc文件?

解决方案 //docs.python.org/dev/whatsnew/2.6.html#interpreter-changesrel =nofollow noreferrer>Python 2.6中的新功能 - 解释器变更:


Python现在可以防止
通过
编写.pyc或.pyo文件,提供 - B 切换到Python
解释器,或通过设置
PYTHONDONTWRITEBYTECODE 环境
变量,然后运行
解释程序。此设置可用
作为Python程序的
sys.dont_write_bytecode 变量和
Python代码可以将值更改为
修改解释器的行为。


更新2010-11-27:Python 3.2通过引入 .pyc 文件解决了混淆源文件夹的问题一个特殊的 __ pycache __ 子文件夹,请参阅 Python 3.2 - PYC存储库目录中的新增功能。


Can I run the python interpreter without generating the compiled .pyc files?

解决方案

From "What’s New in Python 2.6 - Interpreter Changes":

Python can now be prevented from writing .pyc or .pyo files by supplying the -B switch to the Python interpreter, or by setting the PYTHONDONTWRITEBYTECODE environment variable before running the interpreter. This setting is available to Python programs as the sys.dont_write_bytecode variable, and Python code can change the value to modify the interpreter’s behaviour.

Update 2010-11-27: Python 3.2 addresses the issue of cluttering source folders with .pyc files by introducing a special __pycache__ subfolder, see What's New in Python 3.2 - PYC Repository Directories.

这篇关于如何避免.pyc文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆