Skip to content

Commit 7fab7f6

Browse files
chore: Recommend python -m asyncio instead of Jupyter Notebook (#511)
1 parent fec206a commit 7fab7f6

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
1212

1313
Headless execution is supported for all browsers on all platforms.
1414

15-
* [Usage](#usage)
15+
- [Usage](#usage)
1616
- [Record and generate code](#record-and-generate-code)
1717
- [Sync API](#sync-api)
1818
- [Async API](#async-api)
1919
- [With pytest](#with-pytest)
2020
- [Interactive mode (REPL)](#interactive-mode-repl)
21-
* [Examples](#examples)
21+
- [Examples](#examples)
2222
- [Mobile and geolocation](#mobile-and-geolocation)
2323
- [Evaluate JS in browser](#evaluate-js-in-browser)
2424
- [Intercept network requests](#intercept-network-requests)
25-
* [Documentation](#documentation)
26-
* [Is Playwright ready?](#is-playwright-ready)
27-
* [Migration from the pre-release versions](#migration-from-the-pre-release-versions)
25+
- [Documentation](#documentation)
26+
- [Is Playwright ready?](#is-playwright-ready)
27+
- [Migration from the pre-release versions](#migration-from-the-pre-release-versions)
2828

2929
## Usage
3030

@@ -66,8 +66,11 @@ with sync_playwright() as p:
6666
#### Async API
6767

6868
If you app is based on the modern asyncio loop and you are used to async/await constructs,
69-
Playwright exposes Async API for you. You should also use this API inside the Jupyter Notebook
70-
and other REPL frameworks that are already based on asyncio.
69+
Playwright exposes Async API for you. You should use this API inside a Python REPL supporting `asyncio` like with `python -m asyncio`
70+
71+
```console
72+
$ python -m asyncio
73+
```
7174

7275
```py
7376
import asyncio
@@ -115,7 +118,11 @@ Blocking REPL, as in CLI:
115118
>>> playwright.stop()
116119
```
117120

118-
Async REPL such as Jupyter Notebook:
121+
Async REPL such as `asyncio` REPL:
122+
123+
```console
124+
$ python -m asyncio
125+
```
119126

120127
```py
121128
>>> from playwright.async_api import async_playwright
@@ -178,6 +185,7 @@ async def main():
178185

179186
asyncio.run(main())
180187
```
188+
181189
</details>
182190

183191
#### Evaluate JS in browser
@@ -201,6 +209,7 @@ with sync_playwright() as p:
201209
print(dimensions)
202210
browser.close()
203211
```
212+
204213
<details>
205214
<summary>Async variant</summary>
206215

@@ -225,6 +234,7 @@ async def main():
225234

226235
asyncio.run(main())
227236
```
237+
228238
</details>
229239

230240
#### Intercept network requests
@@ -248,6 +258,7 @@ with sync_playwright() as p:
248258
page.goto("http://todomvc.com")
249259
browser.close()
250260
```
261+
251262
<details>
252263
<summary>Async variant</summary>
253264

@@ -271,6 +282,7 @@ async def main():
271282

272283
asyncio.run(main())
273284
```
285+
274286
</details>
275287

276288
## Documentation
@@ -288,12 +300,14 @@ every release, but we promise to not break it anymore!
288300
## Migration from the pre-release versions
289301

290302
The API has changed since the last 0.170.0 version:
303+
291304
- Snake case notation for methods and arguments:
292305

293306
```py
294307
# old
295308
browser.newPage()
296309
```
310+
297311
```py
298312
# new
299313
browser.new_page()

0 commit comments

Comments
 (0)