This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [doc] Wrong argument name in documentation for pipes.Template.open
Type: behavior Stage:
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, ilai, iritkatriel, xtreak
Priority: normal Keywords:

Created on 2019-10-16 08:13 by ilai, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg354781 - (view) Author: Ilaï (ilai) Date: 2019-10-16 08:13
Documentation for the pipes module indicates that the second argument of open()
is "mode", but it is actually "rw".

Python 3.7.4 (default, Oct  4 2019, 06:57:26)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pipes import Template; Template().open('/tmp/f', mode='r')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: open() got an unexpected keyword argument 'mode'

Python 2.7.16 (default, Mar 11 2019, 18:59:25)
[GCC 8.2.1 20181127] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pipes import Template; Template().open('/tmp/f', mode='r')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: open() got an unexpected keyword argument 'mode'

https://docs.python.org/3/library/pipes.html#pipes.Template.open
msg354812 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-10-16 18:28
Semantically mode makes sense to me though rw is correct and Template.open docstring has rw. There are docs like unittest where the keyword arguments are slightly different from the actual keyword arguments in the assert helpers. I guess it's slightly unfortunate that Template.open got rw as keyword argument while open uses mode as keyword argument.
msg407123 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-11-27 00:44
It's documented as a positional arg:

Template.open(file, mode)
https://docs.python.org/3/library/pipes.html#pipes.Template.open


but accepts it also as the kwarg "rw".

So these are ok:
from pipes import Template; Template().open('/tmp/f', rw='r')
from pipes import Template; Template().open('/tmp/f', 'r')

And this is not:
from pipes import Template; Template().open('/tmp/f', mode='r')
History
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82678
2021-11-27 00:44:38iritkatrielsetnosy: + iritkatriel
title: Wrong argument name in documentation for pipes.Template.open -> [doc] Wrong argument name in documentation for pipes.Template.open
messages: + msg407123

versions: + Python 3.10, Python 3.11, - Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8
type: behavior
2019-10-16 18:28:17xtreaksetnosy: + xtreak
messages: + msg354812
2019-10-16 08:13:45ilaicreate