minimum install & pickling

Aaron "Castironpi" Brady castironpi at gmail.com
Thu Sep 18 02:54:49 CEST 2008


On Sep 17, 6:06 pm, greg <g... at cosc.canterbury.ac.nz> wrote:
> Aaron "Castironpi" Brady wrote:
> > Even a function created from raw bytecode string can't do anything
> > without __import__ or 'open'.
>
> Not true:
>
>    for cls in (1).__class__.__bases__[0].__subclasses__():
>      if cls.__name__ == "file":
>        F = cls
>
>    F(my_naughty_path, "w").write(my_naughty_data)
>
> --
> Greg

You're right, the list is a little longer.  See above, where I renamed
the Lib/ folder.

'import site' failed; use -v for traceback
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> for cls in (1).__class__.__bases__[0].__subclasses__():
...      if cls.__name__ == "file":
...        F = cls
...
>>> F
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'F' is not defined
>>>

'file' here is still defined.

>>> file
<type 'file'>
>>> del __builtins__.file
>>> file
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'file' is not defined

This one stands a chance.



More information about the Python-list mailing list