diff options
author | Christian Heimes <christian@cheimes.de> | 2007-12-08 17:47:40 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-12-08 17:47:40 (GMT) |
commit | a33eb06e3b29cc5df520bbb28261bd370f510932 (patch) | |
tree | c5b1b9e1d8e263a3b05f05be0a1f6292b538e372 /Lib | |
parent | 895627ff27aad563b2ae5b272998f17521b6e415 (diff) | |
download | cpython-a33eb06e3b29cc5df520bbb28261bd370f510932.zip cpython-a33eb06e3b29cc5df520bbb28261bd370f510932.tar.gz cpython-a33eb06e3b29cc5df520bbb28261bd370f510932.tar.bz2 |
Added descriptor for builtins.open.__doc__
Before the change help(open) didn't return anything helpful but the doc string of io.OpenWrapper. Now it shows the user the documentation of io.open.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/io.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -189,6 +189,14 @@ def open(file, mode="r", buffering=None, encoding=None, errors=None, text.mode = mode return text +class _DocDescriptor: + """Helper for builtins.open.__doc__ + """ + def __get__(self, obj, typ): + return ( + "open(file, mode='r', buffering=None, encoding=None, " + "errors=None, newline=None, closefd=True)\n\n" + + open.__doc__) class OpenWrapper: """Wrapper for builtins.open @@ -198,6 +206,8 @@ class OpenWrapper: See initstdio() in Python/pythonrun.c. """ + __doc__ = _DocDescriptor() + def __new__(cls, *args, **kwargs): return open(*args, **kwargs) |