替换open builtin [英] Replacing open builtin

查看:88
本文介绍了替换open builtin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我更换open builtin例如


import main

__main __.__ builtins __。open = None


有没有办法,从这里开始,访问原来的开放功能?


稍微扩展一下,让我说我对原版进行了参考

在名为Isolate的类中打开函数并使用__getattribute__和__setattr__保护此引用

。原来的功能现在是隔离的吗?只能在隔离区内引用。


总之,除了

到__builtins__并且是__getattribute __,__ setattr__安全


问候


RMM

If I replace the open builtin eg

import main
__main__.__builtins__.open=None

Is there any way, from here on, to access the original open function??

Extending this slightly, lets say I put a reference to the original
open function inside a class called Isolate and protect this reference
using __getattribute__ and __setattr__. Is the original function now
isolated and only able to be referenced within Isolate.

In summary, are there any references to builtin functions others than
through __builtins__ and is __getattribute__, __setattr__ secure

Regards

RMM

推荐答案

有人可以推荐用于演示的Python交互式外壳吗?


理想特性(优先顺序):

o可配置字体大小

o全屏模式

o readline支持

o语法着色


我我试过ipython但是,因为它在一个控制台窗口内运行,并且

控制台窗口的可选字体数量有限,所以它并不是很好的工作好吧。


我见过使用某种PyGame实现的shell的演示文稿。

有没有人有这方面的信息?


干杯,

Brian
Can anyone recommend a Python interactive shell for use in presentations?

Ideal characteristics (priority order):
o configurable font size
o full screen mode
o readline support
o syntax coloring

I''ve tried ipython but, since it runs inside a console window, and the
console window has a limited number of selectable fonts, it doesn''t
work terribly well.

I''ve seen presentations using some sort of PyGame implemented shell.
Does anyone have an information on that?

Cheers,
Brian


对不起,应该以__import__为例。

让我们说我抓取导入,将引用存储在Isolate类中

然后将内置导入重定向到Isolate类中的函数

只允许导入某些模块-eg不是系统。

这是安全的吗?

Sorry, should maybe have used __import__ as an example.
Let''s say I grab import, store the reference within the Isolate class
and then redirect the builtin import to a function in the Isolate class
which only allows certain modules to be imported -eg not sys. Would
this be secure?


>>>>> "布赖恩" == Brian Quinlan< br *** @ sweetapp.com>写道:


Brian>任何人都可以推荐一个Python交互式shell用于

Brian>演示文稿?


Brian>我试过ipython但是,因为它在控制台内运行

Brian>窗口,控制台窗口数量有限

Brian>可选择的字体,它的工作效果不是很好。


嗯,您认为控制台窗口中的字体不可读吗?我已经在win32上使用ipython进行了几次演示,而且工作正常

- 但我认为投影机的质量是这里的一个因素......


-

Ville Vainio http:// tinyurl.com/2prnb
>>>>> "Brian" == Brian Quinlan <br***@sweetapp.com> writes:

Brian> Can anyone recommend a Python interactive shell for use in
Brian> presentations?

Brian> I''ve tried ipython but, since it runs inside a console
Brian> window, and the console window has a limited number of
Brian> selectable fonts, it doesn''t work terribly well.

Hmm, do you consider the fonts in a console window unreadable? I''ve
given a few presentations using ipython on win32 and it worked alright
- but I suppose the projector quality is a factor here...

--
Ville Vainio http://tinyurl.com/2prnb


这篇关于替换open builtin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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