mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #34642 -- Added File.open() support for *args and **kwargs.
This commit is contained in:
parent
ecb6085f6f
commit
369b498219
5 changed files with 27 additions and 5 deletions
|
@ -46,11 +46,12 @@ The ``File`` class
|
|||
|
||||
The read/write mode for the file.
|
||||
|
||||
.. method:: open(mode=None)
|
||||
.. method:: open(mode=None, *args, **kwargs)
|
||||
|
||||
Open or reopen the file (which also does ``File.seek(0)``).
|
||||
The ``mode`` argument allows the same values
|
||||
as Python's built-in :func:`python:open()`.
|
||||
as Python's built-in :func:`python:open()`. ``*args`` and ``**kwargs``
|
||||
are passed after ``mode`` to Python's built-in :func:`python:open`.
|
||||
|
||||
When reopening a file, ``mode`` will override whatever mode the file
|
||||
was originally opened with; ``None`` means to reopen with the original
|
||||
|
@ -58,6 +59,10 @@ The ``File`` class
|
|||
|
||||
It can be used as a context manager, e.g. ``with file.open() as f:``.
|
||||
|
||||
.. versionchanged:: 5.0
|
||||
|
||||
Support for passing ``*args`` and ``**kwargs`` was added.
|
||||
|
||||
.. method:: __iter__()
|
||||
|
||||
Iterate over the file yielding one line at a time.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue