bpo-40561: Add docstrings for webbrowser open functions (GH-19999) · python/cpython@ef7973a

File tree

2 files changed

lines changed

  • Misc/NEWS.d/next/Documentation

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -69,6 +69,14 @@ def get(using=None):

6969

# instead of "from webbrowser import *".

7070
7171

def open(url, new=0, autoraise=True):

72+

"""Display url using the default browser.

73+
74+

If possible, open url in a location determined by new.

75+

- 0: the same browser window (the default).

76+

- 1: a new browser window.

77+

- 2: a new browser page ("tab").

78+

If possible, autoraise raises the window (the default) or not.

79+

"""

7280

if _tryorder is None:

7381

with _lock:

7482

if _tryorder is None:

@@ -80,9 +88,17 @@ def open(url, new=0, autoraise=True):

8088

return False

8189
8290

def open_new(url):

91+

"""Open url in a new window of the default browser.

92+
93+

If not possible, then open url in the only browser window.

94+

"""

8395

return open(url, 1)

8496
8597

def open_new_tab(url):

98+

"""Open url in a new page ("tab") of the default browser.

99+
100+

If not possible, then the behavior becomes equivalent to open_new().

101+

"""

86102

return open(url, 2)

87103
88104
Original file line numberDiff line numberDiff line change

@@ -0,0 +1 @@

1+

Provide docstrings for webbrowser open functions.