Returning a custom file object (Python 3)

Marko Rauhamaa marko at pacujo.net
Thu May 28 01:29:05 EDT 2015


Ben Finney <ben+python at benfinney.id.au>:

> It seems the existing ‘open’ implementation doesn't allow you to
> override the type of object returned.

The question is, can you assign to the builtin namespace. I'm guessing
you can't.

Within a module, you can simply do:

   open = MyFile

Also, in other modules, you can:

   from myfile import open


Marko



More information about the Python-list mailing list